-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcollect.py
43 lines (32 loc) · 825 Bytes
/
collect.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
# taaraxtak
# nick merrill
# 2021
#
# create-tables.py - defines the Postgres tables.
# this runs always.
import time
import schedule
import logging
from funcy import partial
from src.shared.utils import configure_logging, run_threaded
from src.w3techs.collect import collect as w3techs_collect
from src.ooni.collect import collect as ooni_collect
from config import config
#
# setup
#
configure_logging()
logger = logging.getLogger("taaraxtak:collect")
# connect to the db
postgres_config = config['postgres']
# configure scrapers for the db
w3techs = partial(w3techs_collect, postgres_config)
ooni = partial(ooni_collect, postgres_config)
#
# run
#
schedule.every().day.at('09:00').do(run_threaded, w3techs)
schedule.every(10).minutes.do(run_threaded, ooni)
while 1:
schedule.run_pending()
time.sleep(1)