pyspider README

The project's README from github.com/binux/pyspider. As one markdown file: README.md.

pyspider Build Status Coverage Status

A Powerful Spider(Web Crawler) System in Python.

Tutorial: http://docs.pyspider.org/en/latest/tutorial/
Documentation: http://docs.pyspider.org/
Release notes: https://github.com/binux/pyspider/releases

Sample Code

from pyspider.libs.base_handler import *


class Handler(BaseHandler):
    crawl_config = {
    }

    @every(minutes=24 * 60)
    def on_start(self):
        self.crawl('http://scrapy.org/', callback=self.index_page)

    @config(age=10 * 24 * 60 * 60)
    def index_page(self, response):
        for each in response.doc('a[href^="http"]').items():
            self.crawl(each.attr.href, callback=self.detail_page)

    def detail_page(self, response):
        return {
            "url": response.url,
            "title": response.doc('title').text(),
        }

Installation

WARNING: WebUI is open to the public by default, it can be used to execute any command which may harm your system. Please use it in an internal network or enable need-auth for webui.

Quickstart: http://docs.pyspider.org/en/latest/Quickstart/

Contribute

TODO

v0.4.0

License

Licensed under the Apache License, Version 2.0

pyspider (binux/pyspider)

Searching Database…

16.8K ·GitHub
archived
这是什么东西?pyspider 是一个用 Python 编写的强大网络爬虫系统:你用 Python 编写爬取脚本,并通过内置的网页界面管理你的爬取项目。
它是我导入代码里用的库,还是直接运行的工具?是直接运行的工具——它是一个自带 WebUI 的完整爬虫系统,不是库。你的爬取逻辑放在 Python 脚本里,由系统帮你执行、调度和监控。
怎么把它跑起来?先用 'pip install pyspider' 安装,然后运行 'pyspider' 命令,再在浏览器里打开 WebUI。仓库里也提供了 Dockerfile。
用之前需要先配置数据库或消息队列吗?快速上手不需要——但规模大了以后,它可以通过 SQLAlchemy 接入 MySQL、MongoDB、Redis、SQLite、Elasticsearch 或 PostgreSQL 做存储,并使用 RabbitMQ、Redis 或 Kombu 作为消息队列。
把管理面板暴露出去之前有什么坑吗?有——WebUI 默认对公网开放,可能被用来执行任意命令,危害你的系统,所以最好把它放在内网里,或者给 WebUI 开启 need-auth 认证。
在 WebUI 里我能做什么?编写和修改爬虫脚本、监控运行中的任务、管理项目、查看抓取结果——整个爬取流程都可以在浏览器里完成。
它能爬依赖 JavaScript 的页面吗?能——爬取 JavaScript 页面是它的核心功能之一,所以并不局限于静态 HTML。
它怎么处理重试和重复访问?任务支持设置优先级、重试、定时执行,以及按页面更新时间重新抓取,所以不用重写脚本就能让结果保持最新。
它能扩展到多台机器吗?能——它采用分布式架构,爬虫可以跑在多台机器上;工作量大时,再搭配一个消息队列和可扩展的数据库后端即可。
Creator
binux
Size
4.1 MB
Stars
16.8K
Age
12y
Commits · 90 Days