简体   繁体   English

xidel模板从按钮标签中提取

[英]xidel template extract from button tag

xidel https://www.url.com/folder -e "<button class="btn" type="BUTTON" onclick="self.location='https://www.url.com/folder/2'">Next &gt;</button>"

I am trying to extract what's in between the single quotes with this xidel template and I am getting nowhere fast. 我正在尝试使用此xidel模板提取单引号之间的内容,但进展很快。

<button class="btn" type="BUTTON" onclick="self.location='{.}'">Next &gt;</button>

Do I have to escape some characters. 我是否必须转义一些字符。 The syntax is confusing. 语法令人困惑。 I am using this on the commandline on windows, latest version. 我在Windows最新版本的命令行上使用它。

At first I tried: 一开始我尝试过:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<button>{@onClick}</button>*"

but that gave me 5 results of buttons with an onClick attribute, so I needed to be more specific: 但这给了我5个带有onClick属性的按钮结果,所以我需要更具体一些:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<div style='clear:both;text-align:right;'><button>{@onClick}</button></div>"

which will output: self.location='/s/12963528/2/Forced-Return' 它将输出:self.location ='/ s / 12963528/2 / Forced-Return'

So, now we need to get rid of the prefix and single quotes... RegEx is fine for that: 因此,现在我们需要摆脱前缀和单引号了。RegEx可以:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<div style='clear:both;text-align:right;'><button>{extract(@onClick,'=.(.*).',1)}</button></div>"

This will output what you wanted: /s/12963528/2/Forced-Return 这将输出您想要的内容:/ s / 12963528/2 / Forced-Return

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM