Created
June 20, 2020 10:05
-
-
Save ahmedshahriar/82bccb7fba6be545725980516a47a277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scrapy | |
class QuotesSpider(scrapy.Spider): | |
name = "quotes" | |
start_urls = [ | |
'http://quotes.toscrape.com/page/1/', | |
] | |
def parse(self, response): | |
for quote in response.css('div.quote'): | |
yield { | |
'text': quote.css('span.text::text').get(), | |
'author': quote.css('span small::text').get(), | |
'tags': quote.css('div.tags a.tag::text').getall(), | |
} | |
next_page = response.css('li.next a::attr(href)').get() | |
if next_page is not None: | |
yield response.follow(next_page, callback=self.parse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment