Scrapy没找到桌子 [英] Scrapy not finding table

查看:147
本文介绍了Scrapy没找到桌子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 http:/ /www.oddsportal.com/basketball/usa/nba-2014-2015/results/

我想要的特定表有class =table-main

The particular table I want has class="table-main"

从scrapy response.xpath('// table')运行

running from scrapy response.xpath('//table')

In [28]:  response.xpath('//table')
Out[28]:
[<Selector xpath='//table' data=u'<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t<td c
lass="bol'>,
 <Selector xpath='//table' data=u'<table class="table-main top-event">\n\t\t\t'>
,
 <Selector xpath='//table' data=u'<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>\n\t\
t\t\t\t\t\t<tab'>,
 <Selector xpath='//table' data=u'<table class="rm-bonus-offer">\n\t\t\t\t\t\t\t
\t<'>,
 <Selector xpath='//table' data=u'<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>\n\t\
t\t\t\t\t\t<tab'>,
 <Selector xpath='//table' data=u'<table class="rm-bonus-offer">\n\t\t\t\t\t\t\t
\t<'>]

不会返回我想要刮的表。有人可以帮忙吗?

does not return the table I wish to scrape. Can anyone help?

推荐答案

Selector(response).xpath('//table[contains(@class, "table-main")]').extract_first()

我已经测试过,它有效。

I've tested, it works.

请参阅选择器在scrapy doc

See Selectors in scrapy doc

这篇关于Scrapy没找到桌子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆