这是一个分布式爬虫服务器,将爬虫常用的操作在server端封装,爬虫客户端使用socket调研server端封装的接口。 后端数据库用的是mongodb。
可以参考 test_spider_client.py
def get_task(self, dbName, collName, count=1):
def insert_data(self, dbName, collName, data):
def put_task(self, dbName, collName, data):
def change_task_status(self, dbName, collName, data):
任务状态
NOT_CRAWL = 0
CRAWLING = 1
CRAWL_SUCCESS = 2
CRAWL_FAIL= 3
INVALID_TASK = 4
crawler中是qq音乐的爬虫
python run_server.py
# 初始化歌单任务
python run_crawler.py -s qq -t init_playlist_tasks
# 抓取歌单列表
python run_crawler.py -s qq -t crawl_playlist_index
# 抓取歌单详情
python run_crawler.py -s qq -t crawl_playlist