PySpiderPython 爬蟲程序
PySipder 是一個 Python 爬蟲程序
演示地址:http://demo.pyspider.org/
使用 Python 編寫腳本,提供強大的 API
Python 2&3
強大的 WebUI 和腳本編輯器、任務監(jiān)控和項目管理和結(jié)果查看
支持 JavaScript 頁面
后端系統(tǒng)支持:MySQL, MongoDB, SQLite, Postgresql
支持任務優(yōu)先級、重試、定期抓取等
分布式架構(gòu)
示例代碼:
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(),
}
評論
圖片
表情
