Skip to main content

A light weight crawler

Project description

sbcrawler

light weight crawler

轻量级的爬虫框架sbcrawler

写这个框架的动机

  1. 平时写爬虫过程中,发现通常不需要什么高大上的异步、并发、分布式等功能。
  2. 小需求对防止被封,中断继续,日志进度等方面有更多重复性的代码。
  3. sbcrawler就是实现一个最简单的爬虫框架,让你可以专注于写内容抽取逻辑。

特点

  • 单进程,非异步
  • 断点续爬
  • 错误日志记录

用法示例

# -*- coding: utf-8 -*-

from sbcrawler import Crawler

class MyCrawlerExample(Crawler):

    start_url = "https://xxx.xxx.com/xxx/"  # 起始种子url

    allowed_domain =  "https://xxx.xxx.com/"   # 限制域,要带http

    def extract_links(self, html, task):
        # 抽取链接 加到爬取任务列表
        if task.depth == 0 or task.depth == 1:
            html = html.find('.module_summary', first=True)
        if task.depth == 2:
            html = html.find("#in_list_main > table > tr:nth-child(6)", first=True)
        if task.depth == 3:
            return

        super().extract_links(html, task)

    def extract_content(self, html, task):
        if task.depth == 3:
            title = html.find('#title', first=True)
            article = html.find('#article', first=True)
            return {'title': title.full_text, 'article': article.full_text}


if __name__ == "__main__":
    crawler = MyCrawlerExample()
    crawler.start()

安装

pip install git+https://github.com/ffteen/sbcrawler.git

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbcrawler-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sbcrawler-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file sbcrawler-0.1.1.tar.gz.

File metadata

  • Download URL: sbcrawler-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

File hashes

Hashes for sbcrawler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a6daad4d2890ab2bc89fc345348197b392bec78322b176bf63178978253df053
MD5 64b4834feb294f39adec163f6961449d
BLAKE2b-256 3d7909ae99ce9aa1c944b15d6ddf6f852a4bddf029d308ad2c83d36bf25f3d23

See more details on using hashes here.

File details

Details for the file sbcrawler-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sbcrawler-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

File hashes

Hashes for sbcrawler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b70c2e743f7eed8b9e06195a016e9e72d302ed4dc226ebe46aa438f89de64592
MD5 4a6e597fa8b6fcabf55ebc0cd25f16cd
BLAKE2b-256 40998b2862c2c6f7c76aa7be895b7bb01eb11f5b3ad8c64fd9c70e041d6fad89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page