Guest User

Untitled

a guest
Dec 12th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import scrapy
  2.  
  3.  
  4. class QuotesSpider(scrapy.Spider):
  5.     name = 'quotes'
  6.     start_urls = [
  7.         'https://www.cannabisonlinedispensary.net/product-category/marijuana-strains/'
  8.     ]
  9.  
  10.     def parse(self, response):
  11.         for quote in response.css('div.card card-product'):
  12.             yield {
  13.                 'category': quote.css('li.product h6 a::text').get(),
  14.                 'sort': quote.css('div.content a.shop-item-title-link::text').get(),
  15.             }
  16.  
  17.         next_page = response.css('.next::attr("href")').get()
  18.         if next_page is not None:
  19.             yield response.follow(next_page, self.parse)
Add Comment
Please, Sign In to add comment