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.2.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.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sbcrawler-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 6d46bd4b081e1723c9953603481e26a550d263450f0a5fbf35f2a591453a9471
MD5 dd7f51905e159c5603b422086e4d153e
BLAKE2b-256 95d6504e5efa4b7859a562543b64953185ae90f960b9c33440887752c7853ad3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sbcrawler-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b821b8d405af909d444f7d630b6ba583c3fc8d1e02889789619c3539a7907e77
MD5 37caaa588588fe7fd3d865091f1f6fb0
BLAKE2b-256 cab5084b7398b05b699aa4fcbc1f6cf3d19212c50e4e65667ecc04511f6895ef

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