pyspider 介紹

2023-02-16 16:06 更新

pyspider

一個強大的python爬蟲(Web Crawler) .嘗試它!

  • 用python寫腳本
  • 強大的網(wǎng)頁腳本編輯界面,任務(wù)監(jiān)控器,項目管理器和結(jié)構(gòu)查看器
  • MySQL, MongoDB, Redis, SQLite, Elasticsearch各種數(shù)據(jù)庫引擎; PostgreSQL數(shù)據(jù)庫系統(tǒng) 和 SQLAlchemy數(shù)據(jù)庫ORM模型 作為數(shù)據(jù)庫的支持
  • RabbitMQ, Beanstalk, Redis and Kombu 作為信息隊列
  • 任務(wù)優(yōu)先級, 失敗重試, 定期的, 周期性的重復(fù)采集 等等...
  • 分布式架構(gòu), 采集 Javascript 頁面, Python 2&3, 等等...

教程: http://docs.pyspider.org/en/latest/tutorial/文檔: http://docs.pyspider.org/發(fā)布日志: https://github.com/binux/pyspider/releases

簡單的演示

    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(),
            }

例子

安裝 pip install pyspider
命令行運行 pyspider
瀏覽器查看 http://localhost:5000/
快速入門: http://docs.pyspider.org/en/latest/Quickstart/


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號