Advertisement
Zer0Div

Untitled

Jul 14th, 2022
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. import scrapy
  2.  
  3. class AstroSpider(scrapy.Spider):
  4.     name = "Astro"
  5.     allowed_domains = ['www.astrolighting.com']
  6.     start_urls = ['https://www.astrolighting.com/products']
  7.  
  8.    
  9.  
  10.     def parse(self, response, **kwargs):
  11.         for link in response.css('article.product-listing-item a::attr(href)'):
  12.             #print(link)
  13.             yield response.follow(link.get(), callback=self.parse_items)
  14.  
  15.     def parse_items(self, response):
  16.        
  17.         for link in response.css('div.variants.variants--large a::attr(href)'):
  18.             print(link.get())
  19.             yield response.follow(link.get(), callback=self.parse_item)
  20.  
  21.     def parse_item(self, response):
  22.         print(f"!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  23.         yield {
  24.             'name': response.css('div.detail__right h1::text').get(),
  25.             'material': response.css('div.detail__right p span::text').getall()[0],
  26.             'id': response.css('div.detail__right p span::text').getall()[1].strip()
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement