-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.py
56 lines (41 loc) · 1.37 KB
/
index.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
import os, sys
from database import Database
from database import url_bases
from utils import *
def getCommand(args):
if len(args) == 1:
return False
command = args[1]
if command == '--help':
getHelp()
elif command == '--scrape':
if len(args) == 2:
print("No country code found hence program is closed.")
return False
url_base = getCountryWebsite(url_bases,countryCode=args[2])
if not url_base:
print("Country code is invalid hence program is closed.")
return False
DB = Database(credentials)
scrapeData(DB, credentials, url_base)
elif command == '--info-country':
getInfo(url_bases)
else:
print("No command found hence program is closed.")
# give credentials file path or initialize your database here
# example for credentials file:
# {
# "dbUrl": "your_db_url",
# "collectionName":"your_collection_name_if_exists",
# "dbName": "your_db_name",
# }
credentialFile = os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "../credentials")
)
credentials = getCredentials(credentialFile)
if credentials is None:
sys.exit("No credentials found hence program is closed.")
if __name__ == "__main__":
os.system('cls' if os.name=='nt' else 'clear')
command = getCommand(sys.argv)
sys.exit()