schulman86

Untitled

Jul 25th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import scrapy
  2. from scrapy.spiders import CrawlSpider, Rule
  3. from scrapy.linkextractors import LinkExtractor
  4.  
  5. class VianorcspdrSpider(CrawlSpider):
  6. name = 'vianorcspdr'
  7. allowed_domains = ['vianor-barnaul.ru']
  8. start_urls = ['https://vianor-barnaul.ru/shiny/hankook/6742/tovar-Ц0000136558.html']
  9. rules = (
  10. Rule(LinkExtractor(allow=('shiny',)), follow=True),
  11. Rule(LinkExtractor(allow=('tovar',)), callback='parse'),
  12. )
  13.  
  14. def parse(self, response):
  15. name = response.xpath('//*[@id="content_main"]/h1/text()').extract()
  16. price = response.xpath('//*[@id="catalog"]/div/div[2]/p[2]/span/@rel').extract()
  17. link = response.url
  18. yield {
  19. 'name': name,
  20. 'price': price,
  21. 'link': link,
  22. }
  23.  
Add Comment
Please, Sign In to add comment