Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- name = 'author'
- start_urls = ['http://quotes.toscrape.com/']
- def parse(self, response):
- # follow links to author pages
- for href in response.css('.author + a::attr(href)'):
- yield response.follow(href, self.parse_author)
- # follow pagination links
- for href in response.css('li.next a::attr(href)'):
- yield response.follow(href, self.parse)
- def parse_author(self, response):
- def extract_with_css(query):
- return response.css(query).get(default='').strip()
- yield {
- 'name': extract_with_css('h3.author-title::text'),
- 'birthdate': extract_with_css('.author-born-date::text'),
- 'bio': extract_with_css('.author-description::text'),
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement