刮擦Trulia桌子

2024-04-27 18:39:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我在找表中的数据

http://www.trulia.com/school-district/CA-San_Francisco_County/San_Francisco_Unified/

当搜索第一个元素“Yu(alice Fong)Elementary School”的Xpath时,我得到:

//*[@id="elementary_tab_content"]/table/tbody/tr[1]/td[2]/a

当我寻找:

^{pr2}$

我得到了回应,但还不是我需要的

当我尝试:

response.xpath('//*@id="elementary_tab_content"]/table/tbody/tr[1]/td[2]/a').extract()

我什么也没得到,事实上我加上'/tbody'后答案是空的

response.xpath('//*[@id="elementary_tab_content"]/table/tbody').extract()

如何用scray提取这个表的数据?在


Tags: 数据idhttpresponsetableextractcontenttab