This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scraper.py
92 lines (70 loc) · 2.58 KB
/
scraper.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from core.utils import printUserInfo, clear
def initialization(platform, credential):
printUserInfo(platform, credential)
if (platform == "CodeChef"):
from core.cc_scrapper import CC_Scrapper
from core.utils import setupSeleniumDriver
try:
driver = setupSeleniumDriver()
codechef_scraper = CC_Scrapper(
username=credential.get("username"),
password=credential.get("password"),
driver=driver)
# Login first LOL
if codechef_scraper.LOGIN():
# Start the freaking show! :p
codechef_scraper.getSubmissions()
codechef_scraper.LOGOUT()
else:
codechef_scraper.getSubmissions()
except Exception as error:
print(error)
finally:
driver.quit()
elif (platform == "Hackerrank"):
from core.hr_scrapper import HR_Scrapper
from core.utils import setupSeleniumDriver
try:
driver = setupSeleniumDriver()
hackerrank_scraper = HR_Scrapper(
username=credential.get("username"),
password=credential.get("password"),
driver=driver)
# Login first :D
if hackerrank_scraper.LOGIN():
# Start the freaking show! :p
# Hackerrank uses tracks
for track in credential.get("tracks"):
hackerrank_scraper.getTrack(track)
# Logout :D
hackerrank_scraper.LOGOUT()
except Exception as error:
print(error)
finally:
driver.quit()
else:
print("Currently supported: ")
from core.constants import SUPPORTED
for idx, val in enumerate(SUPPORTED):
print(f"{idx}. {val}")
exit()
def main():
try:
from credentials import ACCOUNTS
accounts = ACCOUNTS().getAccounts()
accountsList = list(accounts)
except ModuleNotFoundError:
print("Please setup a credentials.py file!")
# TODO: Add check for default username and passowrd.
if accountsList:
print("Found the following Account(s): ")
for index, account in enumerate(accountsList):
print(f"{index+1}. {account}")
option = int(input("Enter your choice: ")) - 1
initialization(accountsList[option],
accounts.get(accountsList[option]))
else:
print("Please define accounts in credentials.py")
if __name__ == "__main__":
clear()
main()