-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetFivePlayers.py
30 lines (24 loc) · 972 Bytes
/
GetFivePlayers.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
from bs4 import BeautifulSoup
import requests
from GetTeammates import GetTeammates
def GetFivePlayers(team_id):
r = requests.get('http://dotamax.com/match/tour_team_players/?team_id={}'.format(team_id))
soup = BeautifulSoup(r.text,'lxml')
list = []
for index in range(0,10):
if soup.select('#matchrow_{} a'.format(index)) != []:
tuple = (soup.select('#matchrow_{} > td:nth-of-type(2)'.format(index))[0].text,soup.select('#matchrow_{} a'.format(index))[0].get('href').split('/')[3])
list.append(tuple)
else:
continue
accounts_list = []
for i in GetTeammates(team_id):
accounts_list.append(i['account_id'])
fivePlayerslist = []
while len(fivePlayerslist) < 5:
for accounts in sorted(list, reverse=True):
if accounts[1] in accounts_list:
fivePlayerslist.append(accounts[1])
else:
continue
return fivePlayerslist