Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 从按钮标签提取xidel模板 西德尔https://www.url.com/folder -e“下一步”_Templates_Xidel - Fatal编程技术网

Templates 从按钮标签提取xidel模板 西德尔https://www.url.com/folder -e“下一步”

Templates 从按钮标签提取xidel模板 西德尔https://www.url.com/folder -e“下一步”,templates,xidel,Templates,Xidel,我正试图用这个xidel模板提取单引号之间的内容,但我进展很快 xidel https://www.url.com/folder -e "<button class="btn" type="BUTTON" onclick="self.location='https://www.url.com/folder/2'">Next &gt;</button>" 下一步 我是否必须逃避某些角色。语法混乱。我正在windows上的命令行上使用此命令,最新版本。起初我尝试:

我正试图用这个xidel模板提取单引号之间的内容,但我进展很快

xidel https://www.url.com/folder -e "<button class="btn" type="BUTTON" onclick="self.location='https://www.url.com/folder/2'">Next &gt;</button>"
下一步
我是否必须逃避某些角色。语法混乱。我正在windows上的命令行上使用此命令,最新版本。

起初我尝试:

<button class="btn" type="BUTTON" onclick="self.location='{.}'">Next &gt;</button>
xidel-shttps://www.fanfiction.net/s/12963528/1/Forced-Return -e“{@onClick}”
但这给了我5个带有onClick属性的按钮结果,所以我需要更具体一些:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<button>{@onClick}</button>*"
xidel-shttps://www.fanfiction.net/s/12963528/1/Forced-Return -e“{@onClick}”
其中将输出:self.location='/s/12963528/2/Forced Return'

所以,现在我们需要去掉前缀和单引号。。。RegEx可以做到这一点:

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

这将输出您想要的:/s/12963528/2/强制返回

谢谢您的帮助。我试着做上面的工作,但它抓住了整个html源代码。我只需要单引号中的url如果可以,发布真实的url和需要提取的文本/属性…
xidelhttps://www.fanfiction.net/s/12963528/1/Forced-Return -e“Next”
我希望这是输出/s/12963528/2/Forced return非常感谢您的帮助,因此,如果没有正则表达式的帮助,xpath和xquery无法正确处理单引号或双引号转义。很高兴知道。在xquery/xpath中,引号可以被“(double)或&apos;(single)替换,但我已经在xidel行中使用了单引号和双引号,xidel解析似乎将它们替换回了“或”,例如在substring-before()和substring-after()中,所以RegEx是我最简单的方法。。。用户BeniBela或Reino(Xidel专家)可能知道如何以不同的方式转义或规避这些引用。如果您只想输出url的路径,那么
-e“$path”
就是您所需要的。@Reino语法会如何寻找它?呃,就是
Xidelhttps://www.url.com/folder -e“$path”
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>"