Scrapy+Xpath+Python:无法抓取数据点

我想在这里抓取网址:

http://img4.mukewang.com/60d14973000124d713630768.jpg

我试过这些:


response.xpath('//header[@class="geodir-entry-header"]/a/@href').extract()


response.xpath('//div[class="geodir-content "]/header/a/@href').extract()


response.xpath('//div[@class="geodir-content "]/header[@class="geodir-entry-header"]/a/@href').extract()

都返回了一个空列表。


慕妹3242003
浏览 138回答 2
2回答

慕桂英4014372

做response.xpath('//h3[@class="geodir-entry-title"]/a/@href').extract() 或者 response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()为你工作?看起来您刚刚错过了h3包含a您需要的标签的标签。

紫衣仙女

您所需要的只是添加您不小心错过的 h3 标签。response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()&如果您只想获取第一个网址,请添加response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract_first()或者response.xpath('//header[@class="geodir-entry-header"]/h3/a/@href').extract()[0]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python