current position:Home>Python scratch crawler

Python scratch crawler

2022-02-02 15:07:33 Panda code

# demo

import scrapy

class QuotesSpider(scrapy.Spider):
    name = 'quotes'
    start_urls = [
        'http://quotes.toscrape.com/tag/humor/',
    ]

    def parse(self, response):
        for quote in response.css('div.quote'):
            yield {
                'author': quote.xpath('span/small/text()').get(),
                'text': quote.css('span.text::text').get(),
            } 

copyright notice
author[Panda code],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202021507321183.html

Random recommended