-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserCollectCode_final.py
More file actions
77 lines (57 loc) · 2.19 KB
/
UserCollectCode_final.py
File metadata and controls
77 lines (57 loc) · 2.19 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
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
import re
import requests
import json
import datetime
import time
import csv
from fake_useragent import UserAgent
def steam_crawling(steamID, ID_Range, fileNum):
userCount=int(fileNum)
for n in range(ID_Range):
time.sleep(35)
steamID = steamID+1
string_ID = str(steamID)
ua = UserAgent()
headers = {'User-Agent':str(ua.random)}
url='https://steamcommunity.com/profiles/'+string_ID+'/games/?tab=all&sort=playtime'
print(url)
try:
html=requests.get(url, headers=headers).text
if 'An error was encountered' in html:
#steamID = steamID + 1
print('429 Error')
time.sleep(1800)
continue
htmlSearch = re.search(r'var rgGames =(.+?);', html, re.S)
gameList = htmlSearch.group(1)
SteamGame = json.loads(gameList)
except:
continue
if (str(SteamGame) != "[]" and 'hours_forever' in gameList): #Private library Check
userCount = userCount+1
f = open('D:/Project/'+str(userCount)+'n'+'.csv', 'w', newline='')
wr=csv.writer(f)
for course in SteamGame:
try:
gameName = '{name}'.format(**course)
gameName = gameName.replace(',',' ') #if 'comma' inside GameName, replace 'space'
gameTime = '{hours_forever}'.format(**course)
gameTime = gameTime.replace(',','') #if'comma' inside playtime, replace 'space'
print(gameName)
print(gameTime)
wr.writerow([string_ID, gameName, gameTime])
except:
continue
f.close()
else:
print('Private account')
continue
# 76561198363008705 end
#76561197960266728+1000 +10
#steamID=76561197960266738+100 complete
#+100+30+20+50+?+10+100
#+100+100+100+100+100+80
#+100+50+218+3+72 + 926 + 430 + 107 + 29 + 369 end
steamID=76561198293008336
now = datetime.datetime.now()
steam_crawling(steamID, 369, 49)