This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteam_exploration.py
73 lines (56 loc) · 1.73 KB
/
steam_exploration.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
from selenium import webdriver
import time
import yaml
def explore_list(steamLoginSecure, options, first, second) -> bool:
cookie = {'name' : 'steamLoginSecure', 'value' : steamLoginSecure }
browser = webdriver.Firefox(options=options)
browser.get('https://store.steampowered.com/explore/')
browser.add_cookie(cookie)
browser.get('https://store.steampowered.com/explore/')
try:
browser.find_element_by_id("discovery_queue_start_link").click()
except:
try:
browser.find_element_by_class_name('discover_queue_empty_refresh_btn').click()
except:
browser.close()
print("Invalid Cookie or some network error! (Cookie could be invalid => need to replace with new one)")
return False
i = 0
j = 0
while i < first:
retries = 0
while j <= second:
try:
browser.find_element_by_class_name('btn_next_in_queue').click()
j += 1
except:
try:
browser.find_element_by_class_name('discover_queue_empty_refresh_btn').click()
except:
try:
browser.find_element_by_class_name('refresh_queue_btn').click()
except:
retries += 1
if retries > 3:
print("Too many errors when clicking through list!")
browser.close()
return False
print("Some error happened. Retrying after 5 sec.")
time.sleep(1)
i += 1
browser.close()
return True
def main():
with open("config.yaml", "r") as ymlfile:
cfg = yaml.safe_load(ymlfile)
options = webdriver.FirefoxOptions()
options.add_argument('--headless')
first = cfg['loops']['first']
second = cfg['loops']['second']
for num,account in enumerate(cfg['steam']):
res = explore_list(account['steamLoginSecure'], options, first, second)
if res:
print(f'Finished account {num}!')
if __name__ == "__main__":
main()