【发布时间】:2020-02-16 10:53:27
【问题描述】:
我想遍历 coinmarketcap 上的 top20 交易所来爬取表格,例如https://coinmarketcap.com/exchanges/fatbtc/
现在我花了几个小时寻找选择器,例如价格
在 Scrapy Shell 中,我尝试了...等等,但都不起作用:
来自插件XPath Helper:
response.xpath('/html/body/div[@id='__next']/div[@class='cmc-app-wrapper.cmc-app-wrapper--env-prod.sc-1mezg3x-0.fUoBLh']/div[@class='container.cmc-main-section']/div[@class='cmc-main-section__content']/div[@class='cmc-exchanges.sc-1tluhf0-0.wNRWa']/div[@class='cmc-details-panel-table.sc-3klef5-0.cSzKTI']/div[@class='cmc-markets-listing.lgsxp9-0.eCrwnv']/div[@class='cmc-table.sc-1yv6u5n-0.dNLqEp']/div[@class='cmc-table__table-wrapper-outer']/div/table/tbody/tr[@class='cmc-table-row.sc-1ebpa92-0.kQmhAn'][1]/td[@class='cmc-table__cell.cmc-table__cell--sortable.cmc-table__cell--right.cmc-table__cell--sort-by__price']').getall()
来自 Chrome 检查器:
response.xpath('/td[@class='cmc-table__cell.cmc-table__cell--sortable.cmc-table__cell--right.cmc-table__cell--sort-by__price']').getall()
来自 Chrome 检查器复制 XPath: :
response.xpath('//*[@id="__next"]/div/div[2]/div[1]/div[2]/div[2]/div/div[2]/div[3]/div/table/tbody/tr[1]/td[5]').extract()
我正在使用 Chrome Inspector,并且从今天开始使用一个名为“Xpath helper”的插件来显示选择器,但我仍然不明白我在那里做什么:(。我真的很感激任何想法访问该数据并让我更好地了解如何找到这些选择器。
【问题讨论】:
标签: xpath scrapy css-selectors