我正在抓取以下页面:http://www.worldfootball.net/all_matches/eng-premier-league-2015-2016/
第一个解析通过,应该得到所有的链接,分数作为文本。我首先遍历所有匹配行:
for sel in response.xpath('(//table[@class="standard_tabelle"])[1]/tr'):
然后得到表格第6列的链接
^{pr2}$但这不会返回任何结果。不过,我在Chrome中尝试了相同的选择器(在table和tr selector之间添加了“tbody”),得到了结果。但是,如果我在scrapy shell中尝试相同的选择器(没有tbody),我只会从第一个选择器得到结果响应.xpath,而没有用下面的链接提取。在
我以前也做过一些这样的循环,但这个简单的事情让我难倒了。有更好的方法来调试这个吗?下面是一些shell输出,我尝试简化我的第二个选择,只选择任何td
In [36]: for sel in response.xpath('(//table[@class="standard_tabelle"])[1]/tr'):
....: sel.xpath('.//td')
....:
没什么。思想?在
我要做的是使用第6列中的这些链接在
href
属性值中包含report
。来自shell的演示:还要注意这一部分:
tr[not(th)]
-这有助于跳过没有相关链接的标题行。在相关问题 更多 >
编程相关推荐