Skip to content

Commit 974818b

Browse files
authored
Performance
1 parent 80d5b63 commit 974818b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

answering.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ def __init__(self):
1616
self.max_delay_interval = 5
1717

1818
# Nothing will happen if these are changed
19-
self.question_tracker = 0
2019
self.question_answering_delay = 0
21-
self.answer_gathering_delay = 2.5
2220
self.limit = 666
2321

2422
# Algo-related variables
23+
self.question_tracker = 0
2524
self.answering_page = ""
2625
self.question_hash = ""
2726
self.answers_in_page = []
@@ -67,8 +66,9 @@ def get_correct_answer(self, browser):
6766
# Click the I don't know button
6867
browser.driver.find_element_by_xpath('/html/body/div[2]/div/div/div[2]/div[2]/div/div[1]/div/div[2]/div[4]/div[5]/a/div/div[2]').click()
6968

70-
self.answer_gathering_delay = random.randint(self.min_delay_interval,self.max_delay_interval)
71-
time.sleep(self.answer_gathering_delay+2)
69+
self.question_answering_delay = random.randint(self.min_delay_interval,self.max_delay_interval)
70+
print(f'Delay set to {self.question_answering_delay+2} seconds. (Questions answered so far: {self.question_tracker})')
71+
time.sleep(self.question_answering_delay+2)
7272

7373
#We loop through all the buttons and we find the one with a different color than blue (that is the correct answer)
7474
for buttons in range(1,5):
@@ -81,7 +81,7 @@ def get_correct_answer(self, browser):
8181
def click_correct_button(self, browser, ans):
8282

8383
self.question_answering_delay = random.randint(self.min_delay_interval,self.max_delay_interval)
84-
print(f'Delay set to {self.question_answering_delay} seconds.')
84+
print(f'Delay set to {self.question_answering_delay} seconds. (Questions answered so far: {self.question_tracker})')
8585
time.sleep(self.question_answering_delay)
8686

8787
# Loop through every answer button and see which one matches with our potential answer
@@ -128,9 +128,4 @@ def answer_question(self, browser):
128128
self.scraped_data[f'{self.question_hash}'] = [self.get_correct_answer(browser)]
129129
self.update_hashes()
130130

131-
132-
133-
134-
135-
136-
131+

0 commit comments

Comments
 (0)