【发布时间】:2019-04-12 14:39:54
【问题描述】:
我正在尝试抓取学校项目的数据,但由于某种原因,我无法弄清楚如何从该页面上的表格中获取数据。我正在scrapy shell中测试,只是没有得到任何数据。这就是我正在尝试的方法
scrapy shell https://www.psacard.com/pop/baseball-cards/1911/turkey-red-cabinets-t3-t9/51453
table = response.xpath('//*[@id="DataTables_Table_0"]/table/tbody')
这是返回[]
我已经尝试过整个表格类以及这样的
table = response.xpath('//*[@class="clear interior-result-table pop-grid items psa table-striped dataTable no-footer dtr-inline"]')
并得到相同的[] 响应
我很难过。有什么想法吗?
【问题讨论】:
-
转到页面源码,如果在xpath中找不到你用过的dom,那就是js页面。对于 js 页面,您需要像 splash 这样的 js 渲染引擎。为此只需请求@Vezunchik