My scrapy code doesn't work, and I have no idea! I want to clean up the Ikea site, I developed CrawlSpider first, which was not specific enough to retrieve all the links to a web page. Therefore, I developed a basic Spider with a yield request method.
Here is my code:
class IkeaSpider(scrapy.Spider) :
name = "Ikea"
allower_domains = ["http://www.ikea.com/"]
start_urls = ["http://www.ikea.com/fr/fr/catalog/productsaz/8/"]
def parse_url(self, response):
for sel in response.xpath('//div[@id="productsAzLeft"]'):
base_url = 'http://www.ikea.com/'
follow_url = sel.xpath('//span[@class="productsAzLink"]/@href').extract()
complete_url = urlparse.urljoin(base_url, follow_url)
request = Request(complete_url, callback = self.parse_page)
yield request
def parse_page(self, response):
And here is the error log:
2016-01-04 22:06:31 [scrapy] ERROR: Spider error processing <GET http://www.ikea.com/fr/fr/catalog/productsaz/8/> (referer: None)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 588, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/scrapy/spiders/__init__.py", line 76, in parse
raise NotImplementedError
NotImplementedError
source
share