我正在制作一个scapy脚本,使用xpath来收集一些页面信息。 我想提取javascript的URL:
<div class="is-hidden-mobile blEntry menu ui_link" data-column="3" onclick="widgetEvCall('handlers.onMenuClicked', event, this, 'http://www.zzz.com/')">
<span class="ui_icon menu"></span>
<span class="detail">Menu </span>
</div>
所以我测试这个命令:
substring-before(substring-after(//@onclick, "'handlers.onMenuClicked', event, this, '"),"'")
它在Xpath测试程序中工作。你知道吗
但是当我把它放到python脚本中时,我遇到了引用问题。所以我试着用反斜杠,但没用:
website = response.xpath('substring-before(substring-after(//@onclick, "\'handlers.onMenuClicked\', event, this"),"\'")').extract()
我在网上看,但我没有看到任何答案:S。我认为我的脚本是复杂的,可以简化,但我不知道如何xD。或者也许有一个解决方案,在脚本中有简单的引号。。。你知道吗
谢谢你的帮助 敬礼
经过两天的寻找,我找到了答案:D
我获取所有xpath答案,并用正则表达式提取URL。你知道吗
敬礼
相关问题 更多 >
编程相关推荐