Extract, create and append using xpath and telegram instant view

瘦欲@ 提交于 2020-03-23 12:02:21

问题


<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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!