-
Notifications
You must be signed in to change notification settings - Fork 120
/
timing_crawl.py
42 lines (38 loc) · 1.29 KB
/
timing_crawl.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
import time
from crawlers import Crawlers
import configparser
config = configparser.ConfigParser()
config.read('config.ini', encoding='utf-8')
crawlers_config = config['Crawlers']
keywords_english = crawlers_config['Keywords_english']
keywords_chinese = crawlers_config['Keywords_chinese']
crawler = Crawlers()
for keyword in keywords_english.split(','):
try:
print(f'keyword: {keyword}')
if crawlers_config['Tiktok_crawler'] == 'True':
print(f'开启tiktok爬虫...')
try:
crawler.tiktok_crawler(keyword)
except:
pass
if keyword == 'funny' or keyword == 'hot':
if crawlers_config['Youtube_crawler'] == 'True':
print(f'开启youtube爬虫...')
try:
crawler.youtube_crawler(keyword)
except:
pass
time.sleep(2)
except:
continue
for keyword in keywords_chinese.split(','):
try:
print(f'keyword: {keyword}')
if crawlers_config['Douyin_crawler'] == 'True':
print(f'开启douyin爬虫...')
crawler.douyin_crawler(keyword)
time.sleep(3)
except Exception as e:
print(f'error: {e}')
continue