fork download
  1. import scrapy
  2.  
  3.  
  4. class QuotesSpider(scrapy.Spider):
  5. name = "quotes"
  6.  
  7. def start_requests(self):
  8. urls = [
  9. 'http://q...content-available-to-author-only...e.com/page/1/',
  10. 'http://q...content-available-to-author-only...e.com/page/2/',
  11. ]
  12. for url in urls:
  13. yield scrapy.Request(url=url, callback=self.parse)
  14.  
  15. def parse(self, response):
  16. page = response.url.split("/")[-2]
  17. filename = 'quotes-%s.html' % page
  18. with open(filename, 'wb') as f:
  19. f.write(response.body)
  20. self.log('Saved file %s' % filename)
Runtime error #stdin #stdout #stderr 0.01s 28384KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'scrapy'