问题
<iframe src="https://expmle.com/subdirectory/sample_title" />
How can I create and append below <a>
tag from above code using XPath
and Telegram Instant view functions?
<a href="https://expmle.com/subdirectory/sample_title">sample_title</a>
I want to extract whole src
and last part of that and use of them to create <a>
tag.
Any suggestions would be very appreciated :)
回答1:
This should work correctly.
<a>: //iframe # Find iframe and convert it to <a>
@set_attr(href, ./@src) # Set href attribute from src
$anchor # Create variable for current <a>
@set_attr(text, ./@href) # We set new attribute for link which will processed by @match function, then @text attribute will be replaced by result of the @match
@match("\\w+_\\w+"): $@/@text # Now we find our future name of the link "sample_name" (this function will replace all in @text by our new name
@prepend(@text): $anchor # And then put this name to his $anchor
回答2:
# append <a> tag below
@after(<a>, href, ./@src, content, ./@src): //iframe
# take everything after the last slash
@match("[^\/]+$", "1"): $@/@content
# move the attribute inside the tag
@append(@content): $@
If the last $@
won't work, just define a variable for <a>
.
来源:https://stackoverflow.com/questions/54786100/extract-create-and-append-using-xpath-and-telegram-instant-view