From 105840aeec07ab927bc99adfb79dd1900dab00e0 Mon Sep 17 00:00:00 2001 From: B Stack Date: Mon, 10 Feb 2020 22:14:59 -0500 Subject: finished run 2020-02-10 --- vooblystats.py | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'vooblystats.py') diff --git a/vooblystats.py b/vooblystats.py index b97b3c8..ee39603 100755 --- a/vooblystats.py +++ b/vooblystats.py @@ -147,6 +147,8 @@ def match(soup): if "ladder/" in i.get('href'): match_dict['Ladder'] = i.text + gameid = match_dict["Match Details"].lstrip("#") + #eprint(gameid) return match_dict def player(match, soup): @@ -161,13 +163,36 @@ def player(match, soup): #print(int(''.join(re.findall('[0-9]',i.get('href'))))) player.append([num]) + # new way to extract name, from the alternate text from the images counts = 1 player_counts = 0 + x=0 + found_names = [] + for k in soup.find_all('td'): + #for i in soup.find_all(name='img'): + for i in k.find_all('img'): + #print("FOO",i) + x += 1 + # always need to skip the first two images with alt text + if x > 2: + for j in re.findall("alt=\"[^\"]+\"",str(i)): + name = j.split('"')[1] + #print("investigating",counts," using name ",name) + if "Age of Empires II: The Conquerors" != name and counts < min(9, player_num + 1) and name not in found_names: + #print("found player number",counts," using name ",name) + player_counts += 1 + player[counts].append(name) + found_names.append(name) + counts+=1 + + # get clan tags + # this is not always sufficient to get names, because of gameid 20365401 Tic@voobly + counts = 1 for i in table.find_all('a'): #this is printing out all name if key in i.get('href'): - player_counts += 1 - name = i.contents[0] - player[counts].append(name) + #player_counts += 1 + #name = i.contents[0] + #player[counts].append(name) try: if re.match("^\[.*]$",i.previous_element): player[counts].append(i.previous_element) # clan @@ -461,13 +486,13 @@ def combine(match,player,score,military,economy,tech,society): "PLAYER," + str(gameid) + "," + str(tp["ID"]) + "," + - tp["Name"] + "," + - ts["Color"] + "," + - tp["Clan"] + "," + + str(tp["Name"]) + "," + + str(ts["Color"]) + "," + + str(tp["Clan"]) + "," + str(tp["New rating"]) + "," + str(tp["Change"]) + "," + str(tp["Winbool"]) + "," + - tp["Civilization"] + "," + + str(tp["Civilization"]) + "," + str(ts["Military Score"]) + "," + str(ts["Economy Score"]) + "," + str(ts["Technology Score"]) + "," + -- cgit