-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks.py
More file actions
42 lines (34 loc) · 848 Bytes
/
tasks.py
File metadata and controls
42 lines (34 loc) · 848 Bytes
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 logging
import random
import time
import traceback
import os
import sys
try:
import settings
except ImportError:
sys.path.append(os.path.dirname(__file__))
import settings
sys.path.append(os.path.join(settings.APP_DIR, 'scrapers'))
import sbs
import afl
LOG_FORMAT = '%(levelno)s: %(asctime)-15s - %(message)s'
logging.basicConfig(filename=settings.LOG_FILE,
level=logging.ERROR,
format=LOG_FORMAT
)
def scrape(module, league):
try:
module.scrape_league(league)
except Exception as e:
a = traceback.format_exc()
logging.error(a)
pass
if __name__ == '__main__':
backoff = random.randint(0, 10)
time.sleep(backoff * 60)
# sbs
scrape(sbs, 'epl')
scrape(sbs, 'bundesliga')
# afl
scrape(afl,'afl')