【发布时间】:2017-05-09 06:32:44
【问题描述】:
我在 Hostelworld.com 上运行以下 scrapy spider 来检索:
- 首页上的大陆、国家和国家网址
-
关注国家/地区网址后来自给定国家/地区的城市列表
def parse_page1(self, response): for sel in response.xpath('//li[@class="accordion-navigation"]//ul[@class="small-block-grid-2 medium-block-grid-4 large-block-grid-6"]/li'): item = HostelWorldItem() item['continent'] = sel.xpath('./../../@id').extract_first() item['country'] = sel.xpath('./a/text()').extract_first() item['country_url'] = sel.xpath('./a/@href').extract_first() yield item url = response.urljoin('%s'%(item['country_url'])) request = scrapy.Request(url, callback=self.parse_dir_contents) request.meta['item'] = item yield request def parse_dir_contents(self, response): item = response.meta['item'] item['city'] = response.xpath('//div[@class="otherlocations"]/li/a/text()').extract_first() yield item
运行时出现以下错误,我找不到解决方法:
scrapy/spiders/__init__.py", line 76, in parse
raise NotImplementedError
NotImplementedError
非常感谢您的帮助!
【问题讨论】:
标签: scrapy scrapy-spider