-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproScrape.py
More file actions
60 lines (35 loc) · 1.42 KB
/
proScrape.py
File metadata and controls
60 lines (35 loc) · 1.42 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
import os
import json
import urllib.request
directory = ''
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
except ValueError:
return ""
while True:
print('Link to game:')
url = input('')
region = find_between(url, 'match-details/', '/')
gameId = find_between(url, region + '/', '?gameHash')
gameHash = url.split('gameHash=')[1]
print(region)
print(gameId)
print(gameHash)
urlString = 'https://acs.leagueoflegends.com/v1/stats/game/{}/{}?gameHash={}'.format(region, gameId, gameHash)
with urllib.request.urlopen(urlString) as url:
json_raw = url.read().decode()
json_file = open('Pro/game/{}.json'.format(str(gameId)), 'wb')
json_file.write(json_raw.encode('utf-8'))
json_file.close
urlString = 'https://acs.leagueoflegends.com/v1/stats/game/{}/{}/timeline?gameHash={}'.format(region, gameId, gameHash)
with urllib.request.urlopen(urlString) as url:
json_raw = url.read().decode()
json_file = open('Pro/timeline/{}.json'.format(str(gameId)), 'wb')
json_file.write(json_raw.encode('utf-8'))
json_file.close
# https://matchhistory.na.leagueoflegends.com/en/#match-details/TRLH1/1002440062?gameHash=a3b08c115923f00d&tab=overview
# https://acs.leagueoflegends.com/v1/stats/game/TRLH1/1002440062/timeline?gameHash=a3b08c115923f00d
# https://acs.leagueoflegends.com/v1/stats/game/TRLH1/1002440062?gameHash=a3b08c115923f00d