-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_base.py
66 lines (48 loc) · 1.96 KB
/
config_base.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from lib.proxy_utils import co_map
class ConfigBase:
class_name = '' # Name given to this program; for printing purposes
polling = {
'start_h': 10,
'end_h': 23,
'wait_minutes': 20,
'bds': 0.5, # Bounds on wait interval
}
sleep_over_weekend = False
driver = '' # 'firefox' or 'puppeteer'
headless = False
# Mailing address and application password
mail_info = {'addr': "", 'app_pw': ""}
# dictionary containing the urls and css or xpath selectors to scrape
check = {} # {`url`: [`selector`]}
##################
# Proxy Inputs #
##################
use_proxy = False
src_countries = [ # locate proxies from these countries
country for country in co_map.keys()
]
# Page load timeout [seconds]
timeout = 30
# Number of spawned processes used to test for working proxies
n_test_workers = 2
working_proxy_limits = {
'lower': 15, # Number of working proxies for new proxies to be imported
'upper': 35, # Number of working proxies for proxy testing to be halted
'timeout': 60 # Timeout when number of working proxies is below lower threshold
}
# Number of retries after which import of a proxy address is abandoned
import_retries = 3
ban_policy = {
'last_n': 20, # Previous n attempts taken into consideration
'min_n': 5, # minimum number of tries before proxy may be removed
'working_ratio': 0.4 # Working/broken threshold below which proxy is removed
}
# Re-import proxy list if existing import is older than this [seconds]
import_file_age_thres = 7200
# Update tested proxy file if existing file is older than this [seconds]
tested_proxy_file_age_thres = 1200
def __init__(self):
assert self.class_name
assert self.check
if hasattr(self, 'driver') and self.driver:
assert self.driver in ['firefox', 'puppeteer']