📜  python 网络爬虫 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:15.496000             🧑  作者: Mango

代码示例1
import scrapy

class BlogSpider(scrapy.Spider):
    name = 'blogspider'
    start_urls = ['https://blog.scrapinghub.com']

    def parse(self, response):
        for title in response.css('.post-header>h2'):
            yield {'title': title.css('a ::text').get()}

        for next_page in response.css('a.next-posts-link'):
            yield response.follow(next_page, self.parse)