-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_scrapper.py
40 lines (34 loc) · 1.22 KB
/
main_scrapper.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
import argparse, sys
from gisaid_scrapper import GisaidCoVScrapper
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
def parse_args():
parser=argparse.ArgumentParser()
parser.add_argument('--headless', '-q', help="Headless mode of scraping (experimental)", type=str2bool, nargs='?', default=False)
args = parser.parse_args()
args.headless = True if args.headless is None else args.headless
return args
def get_credentials():
try:
with open('credentials.txt') as f:
login = f.readline()
passwd = f.readline()
except FileNotFoundError:
print("File not found.")
sys.exit(-1)
return login, passwd
if __name__ == "__main__":
args = parse_args()
login, passwd = get_credentials()
print("Downloading All Files from GISAID to run in nextstrain!!!!!")
scrapper = GisaidCoVScrapper(args.headless)
scrapper.login(login, passwd)
scrapper.load_epicov()
print("All Downloaded")