forked from Boris-code/feapder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (33 loc) · 1.22 KB
/
Copy pathmain.py
File metadata and controls
43 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on 2021-02-08 16:02:02
---------
@summary: 爬虫入口
---------
@author: Boris
"""
from spiders import *
from feapder import ArgumentParser
def crawl_test(args):
spider = test_spider.TestSpider(
redis_key="feapder:test_batch_spider", # redis中存放任务等信息的根key
task_table="batch_spider_task", # mysql中的任务表
task_keys=["id", "url"], # 需要获取任务表里的字段名,可添加多个
task_state="state", # mysql中任务状态字段
batch_record_table="batch_spider_batch_record", # mysql中的批次记录表
batch_name="批次爬虫测试(周全)", # 批次名字
batch_interval=7, # 批次周期 天为单位 若为小时 可写 1 / 24
)
if args == 1:
spider.start_monitor_task() # 下发及监控任务
else:
spider.start() # 采集
if __name__ == "__main__":
parser = ArgumentParser(description="批次爬虫测试")
parser.add_argument(
"--crawl_test", type=int, nargs=1, help="(1|2)", function=crawl_test
)
parser.start()
# 运行
# 下发任务及监控进度 python3 main.py --crawl_test 1
# 采集 python3 main.py --crawl_test 2