我试图从html的以下部分的onclick属性中“选择”链接
<span onclick="Javascript:document.quickFindForm.action='/blah_blah'"
class="specialLinkType"><img src="blah"></span>
但是不能比下面的XPath更进一步
^{pr2}$只会返回
Javascript:document.quickFindForm.action
关于如何用XPath从quickFindForm.action
中找出链接有什么想法吗?在
我使用了xquery,但在xpath中应该是相同的。我使用了一个xpath函数“tokenize”,它根据正则表达式拆分字符串(http://www.xqueryfunctions.com/xq/fn_tokenize.html). 在本例中,我基于“'”拆分字符串
在xpath中应该是:
^{pr2}$如果Scrapy支持XPath字符串函数,这就可以了
它看起来也支持regex。这样的事情应该行得通
^{pr2}$注意:我不能测试第二个解决方案,您必须检查
\'
是否是本例中单引号的正确转义序列。在我在一个Java应用程序中尝试了XPath,但效果良好:
结果:
^{pr2}$相关问题 更多 >
编程相关推荐