-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_bot.py
More file actions
42 lines (33 loc) · 1.45 KB
/
Copy pathstart_bot.py
File metadata and controls
42 lines (33 loc) · 1.45 KB
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
#!/usr/bin/env python3
from selenium import webdriver
from functools import cache
from consts import *
import argparse
def main():
# Arguments for when you execute the file
parser = argparse.ArgumentParser(description='Automatically answer questions on smartrevise.online')
parser.add_argument('-e', '--email', type=str, required=True, help='The email of your account on smartrevise.online')
parser.add_argument('-p', '--password', type=str, required=True, help='The password of your account on smartrevise.online')
parser.add_argument('-l', '--link', type=str, required=True, help='The number at the end of the link where you answer questions')
parser.add_argument('-H', '--headless', type=bool, help='Run in headless mode? True/False')
parser.add_argument('-L', '--limit', type=int, help='How many questions to answer?')
args = parser.parse_args()
# Attribute the arguments to corresponding variables
browser.cred_email = args.email
browser.cred_password = args.password
bot.answering_page = f"https://smartrevise.online/student/revise/Question/{args.link}"
bot.limit = args.limit
if args.headless == True:
browser.headless = True
browser.restart()
# Login to smartrevise
browser.login()
while True:
# If an error occurs while the bot is working, it will simply restart the browser instead of crashing. It ensures stability.
try:
bot.answer_question(browser)
except:
browser.restart()
browser.login()
if __name__ == "__main__":
main()