forked from HelloGitHub-Team/Hydra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (29 loc) · 848 Bytes
/
main.py
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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : XueWeiHan
# E-mail : [email protected]
# Date : 2021-01-22 15:24
# Desc : 运行
import argparse
from hydra.spider import *
SPIDER_MAP = {
"wechat": WeChat, "cnblogs": Cnblogs, "toutiao": Toutiao,
"csdn": Csdn, "zhihu": Zhihu, "juejin": Juejin, "jike": Jike
}
if __name__ == "__main__":
# 1. 设置解析器
parser = argparse.ArgumentParser(description='Script run')
# 2. 定义参数
parser.add_argument('name', metavar='name', type=str)
# 3. 解析命令行
args = parser.parse_args()
name = args.name
spider = SPIDER_MAP.get(name)
if spider:
spider().start()
elif name == "all":
for fi_spider in SPIDER_MAP.values():
fi_spider().start()
else:
print("spider name error.")