schulman86

Untitled

Jul 25th, 2020
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import scrapy
  2.  
  3. class VianorSpider(scrapy.Spider):
  4. name = "vianor"
  5. allowed_domains = ['vianor-barnaul.ru']
  6. start_urls = [
  7. 'https://vianor-barnaul.ru/shiny/shiny-legkovye.html',
  8. ]
  9.  
  10. def parse(self, response):
  11. check = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100', '200', '300']
  12. name = response.xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "gtagclick", " " ))]/text()').getall()
  13. price = response.xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "actual-price", " " ))]/text()').getall()
  14. link = response.xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "gtagclick", " " ))]/@href').getall()
  15. yield {
  16. 'name': name,
  17. 'price': price,
  18. 'link': link,
  19. }
  20. for z in check:
  21. yield scrapy.FormRequest(url="https://vianor-barnaul.ru/assets/snippets/mycatalog/catalog.inc.php",
  22. formdata={'id_c': '9', 'pg': z, 'typshin': 'shiny-legkovye'},
  23. callback=self.parse)
Advertisement
Add Comment
Please, Sign In to add comment