-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainWangyiOneDay.py
50 lines (42 loc) · 1.18 KB
/
mainWangyiOneDay.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
'''
功能:查询一次(指定关键字和来源网站)
'''
from sysdb import SysDb # 数据库
from baidusearcher import baidusearcher # 百度爬虫
from process import searchPageProcess
from process import resultPageProcessWangyi as resultPageProcess
# 关键字
kw = r'737max空难'
# 来源网站限制
sourceWebsite = 'news.163.com'
# 每天搜几个新闻
howManyNewsOneDay = 8
# 使用fiddler吗
certFile = None # "./DO_NOT_TRUST_FiddlerRoot.crt" # None
# 参数合理性检查
pass
# 主逻辑
try:
# 连接数据库
SysDb.connectDataBase('./main.sqlite')
# 初始化所有系统表
SysDb.initAllSysTables(updateStrategy='rewrite')
# 初始化浏览器driver
baidusearcher.initDriver()
# 初始化爬虫
baidusearcher.initSearcher(
keyword=kw,
sourceWebsite=sourceWebsite,
howManyResultWanted=howManyNewsOneDay,
fiddler=certFile,
searchPageProcess=searchPageProcess,
resultPageProcess=resultPageProcess
)
# 爬取一下
baidusearcher.search()
finally:
# 释放数据库
SysDb.disconnectDataBase()
# 释放浏览器driver
baidusearcher.closeDriver()