Guest User

Untitled

a guest
Jun 19th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import scrapy
  3. from scrapy.spiders import Rule
  4. from scrapy.linkextractors import LinkExtractor
  5.  
  6.  
  7. class RastellimarketSpider(scrapy.Spider):
  8.     name = 'rastellimarket'
  9.     allowed_domains = ['shop.rastellimarket.com']
  10.     start_urls = ['https://shop.rastellimarket.com/shop/#!/?page=%s' % page for page in range(1, 1366)]
  11.     rules = (
  12.         Rule(LinkExtractor(allow=('products',)), callback='parse'),
  13.     )
  14.  
  15.     def parse(self, response):
  16.         self.logger.info(response.url)
  17.         yield scrapy.Request(response.url, callback=self.parse_item)
  18.  
  19.     def parse_item(self, response):
  20.         a = response.xpath(".//div[@class='fp-item-image fp-item-image-md']/a/@href").get()
  21.         print(a)
Add Comment
Please, Sign In to add comment