我有一个spider,它必须从这个HTML中找到«next»链接-里面有“»”的链接:
<div id="content-center">
<div class="paginador">
<span class="current">01</span>
<a href="ml=0">02</a>
<a href="ml=0">03</a>
<a href="ml=0">04</a>
<a href="ml=0">»</a>
<a href="ml=0">Last</a>
</div>
</div>
我试着用这只蜘蛛
^{pr2}$不认识链接,有什么想法吗? 你知道怎么解决这个问题吗?在
谢谢!在
我想^{} 能胜任这项工作
您可以在代码中更改以下几点:
应用这些要点:
尝试使用
\u
-转义版本的»
:就像在您的
^{pr2}$.xpath()
调用中一样(注意字符串参数的u"..."
前缀):spider.py文件可能正在使用UTF-8:
因此,您也可以使用
hxs.select(u"//a[text()='»']/@href").extract()
(前缀仍然存在),但是您还需要告诉Python您的.py
编码是什么。在通常在.py文件的顶部使用
# -*- coding: utf-8 -*-
(或等效文件)(例如第一行)。在您可以阅读更多关于Python源代码编码声明here和here。在
相关问题 更多 >
编程相关推荐