-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (32 loc) · 888 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
35
36
37
38
39
40
#!/usr/bin/env python
# encoding: utf-8
"""
@author: william
@contact: 1342247033@qq.com
@site: http://www.xiaolewei.com
@file: main.py
@time: 31/01/2018 17:21
"""
import threading
import requests
import json
import config
from action import dayu, toutiao
from channel import Channel
dayu_pages = config.get('channel.dayu.page_ids', [])
toutiao_pages = config.get('channel.toutiao.page_ids', [])
proxies = []
def build_ip_pool():
global proxies
resp = requests.get(config.get('proxypool.url', 'http://localhost:8000/'))
proxies = json.loads(resp.text)
if __name__ == '__main__':
build_ip_pool()
visit_num = 0
lock = threading.Lock()
channels = [Channel('dayu', lock, proxies, dayu, dayu_pages),
Channel('toutiao', lock, proxies, toutiao, toutiao_pages)]
for t in channels:
t.start()
for t in channels:
t.join()