Showing
5 changed files
with
69 additions
and
0 deletions
Get_Account_Id.py
0 → 100644
1 | +import requests | ||
2 | +from urllib import parse | ||
3 | +name=parse.quote(input("검색을 원하는 유저 이름을 입력하세요")) | ||
4 | +APIKEY="RGAPI-4a16839e-3e5c-4b4e-8b13-1e44b8d621d7" | ||
5 | +headers={ | ||
6 | + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | ||
7 | + "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | ||
8 | + "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
9 | + "Origin": "https://developer.riotgames.com", | ||
10 | + "X-Riot-Token": APIKEY | ||
11 | + } | ||
12 | +API="https://kr.api.riotgames.com/lol/summoner/v4/summoners/by-name/" + name | ||
13 | +getAPI=requests.get(API, headers=headers) | ||
14 | +LOL_API_DATA=getAPI.json() | ||
15 | +def get_account_id(): | ||
16 | + return LOL_API_DATA["accountId"] | ||
17 | +def return_key(): | ||
18 | + return APIKEY | ||
19 | +def return_name(): | ||
20 | + return name |
Get_Game_Id.py
0 → 100644
1 | +import Get_Account_Id | ||
2 | +import requests | ||
3 | +accountid=Get_Account_Id.get_account_id() | ||
4 | +APIKEY=Get_Account_Id.return_key() | ||
5 | +headers = { | ||
6 | + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | ||
7 | + "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | ||
8 | + "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
9 | + "Origin": "https://developer.riotgames.com", | ||
10 | + "X-Riot-Token": APIKEY | ||
11 | + } | ||
12 | +API="https://kr.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountid | ||
13 | +getAPI=requests.get(API, headers=headers) | ||
14 | +LOL_API_DATA=getAPI.json()['matches'] | ||
15 | +def get_game_id(index): | ||
16 | + return LOL_API_DATA[index].get("gameId") | ||
17 | +def get_champ_id(index): | ||
18 | + return LOL_API_DATA[index].get("champion") |
__pycache__/Get_Account_Id.cpython-38.pyc
0 → 100644
No preview for this file type
__pycache__/Get_Game_Id.cpython-38.pyc
0 → 100644
No preview for this file type
matches.py
0 → 100644
1 | +import Get_Account_Id | ||
2 | +import Get_Game_Id | ||
3 | +import requests | ||
4 | +APIKEY=Get_Account_Id.return_key() | ||
5 | +name=Get_Account_Id.return_name().replace(" ","").lower() | ||
6 | +headers = { | ||
7 | + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36", | ||
8 | + "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", | ||
9 | + "Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
10 | + "Origin": "https://developer.riotgames.com", | ||
11 | + "X-Riot-Token": APIKEY | ||
12 | + } | ||
13 | +def game_result(num): | ||
14 | + champid=Get_Game_Id.get_champ_id(num) | ||
15 | + gameid=Get_Game_Id.get_game_id(num) | ||
16 | + API="https://kr.api.riotgames.com/lol/match/v4/matches/" + str(gameid) | ||
17 | + getAPI=requests.get(API, headers=headers) | ||
18 | + LOL_API_DATA=getAPI.json() | ||
19 | + find_user=-1 | ||
20 | + result=" " | ||
21 | + for i in range(0,10): | ||
22 | + if LOL_API_DATA["participants"][i]["championId"]==champid: | ||
23 | + if LOL_API_DATA["participants"][i]["stats"]["win"]==True: | ||
24 | + result="승리" | ||
25 | + else: | ||
26 | + result="패배" | ||
27 | + print(result) | ||
28 | + | ||
29 | + | ||
30 | +for j in range(0,10): | ||
31 | + game_result(j) |
-
Please register or login to post a comment