Ad

Scrapy+Xpath+Python: Datapoint Cannot Be Scraped

- 1 answer

I want to scrape the URLs here: enter image description here

I tried these:

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()

All returned an empty list.

Ad

Answer

Does

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

Work for you?

Looks like you just missed the h3 tag which contains the a tags you need.

Ad
source: stackoverflow.com
Ad