Это звучит как что-то похожее на учебник по документации Scrapy, как показано ниже. В общем, вы можете попытаться сослаться на #follow links to author pages
, щелкнуть правой кнопкой мыши и осмотреть место, чтобы «щелкнуть», чтобы получить css / xpath на нужной веб-странице.
https://docs.scrapy.org/en/latest/intro/tutorial.html
Кроме того, вы можете поделиться тем, что у вас есть. Надеюсь, это поможет!
import scrapy
class AuthorSpider(scrapy.Spider):
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'),
}