mirror of
https://github.com/SocksPls/hltv-api
synced 2025-04-30 07:33:09 +00:00
Repaired get_matches for new layout
This commit is contained in:
parent
8a28c4c77d
commit
a18096ae43
1 changed files with 16 additions and 20 deletions
28
main.py
28
main.py
|
@ -142,29 +142,26 @@ def _get_historical_lineup(player_anchors):
|
||||||
def get_matches():
|
def get_matches():
|
||||||
matches = get_parsed_page("http://www.hltv.org/matches/")
|
matches = get_parsed_page("http://www.hltv.org/matches/")
|
||||||
matches_list = []
|
matches_list = []
|
||||||
upcomingmatches = matches.find("div", {"class": "upcoming-matches"})
|
upcomingmatches = matches.find("div", {"class": "upcomingMatchesSection"})
|
||||||
|
|
||||||
matchdays = upcomingmatches.find_all("div", {"class": "match-day"})
|
matchdays = matches.find_all("div", {"class": "upcomingMatchesSection"})
|
||||||
|
|
||||||
for match in matchdays:
|
for match in matchdays:
|
||||||
matchDetails = match.find_all("table", {"class": "table"})
|
matchDetails = match.find_all("div", {"class": "upcomingMatch"})
|
||||||
|
date = match.find({'span': {'class': 'matchDayHeadline'}}).text.split()[-1]
|
||||||
for getMatch in matchDetails:
|
for getMatch in matchDetails:
|
||||||
matchObj = {}
|
matchObj = {}
|
||||||
|
|
||||||
matchObj['date'] = match.find("span", {"class": "standard-headline"}).text.encode('utf8')
|
matchObj['date'] = date
|
||||||
matchObj['time'] = getMatch.find("td", {"class": "time"}).text.encode('utf8').lstrip().rstrip()
|
matchObj['time'] = getMatch.find("div", {"class": "matchTime"}).text
|
||||||
|
if getMatch.find("div", {"class": "matchEvent"}):
|
||||||
if (getMatch.find("td", {"class": "placeholder-text-cell"})):
|
matchObj['event'] = getMatch.find("div", {"class": "matchEvent"}).text.encode('utf8').strip()
|
||||||
matchObj['event'] = getMatch.find("td", {"class": "placeholder-text-cell"}).text.encode('utf8')
|
|
||||||
elif (getMatch.find("td", {"class": "event"})):
|
|
||||||
matchObj['event'] = getMatch.find("td", {"class": "event"}).text.encode('utf8')
|
|
||||||
else:
|
else:
|
||||||
matchObj['event'] = None
|
matchObj['event'] = getMatch.find("div", {"class": "matchInfoEmpty"}).text.encode('utf8').strip()
|
||||||
|
|
||||||
if (getMatch.find_all("td", {"class": "team-cell"})):
|
if (getMatch.find_all("div", {"class": "matchTeams"})):
|
||||||
matchObj['team1'] = getMatch.find_all("td", {"class": "team-cell"})[0].text.encode('utf8').lstrip().rstrip()
|
matchObj['team1'] = getMatch.find_all("div", {"class": "matchTeam"})[0].text.encode('utf8').lstrip().rstrip()
|
||||||
matchObj['team2'] = getMatch.find_all("td", {"class": "team-cell"})[1].text.encode('utf8').lstrip().rstrip()
|
matchObj['team2'] = getMatch.find_all("div", {"class": "matchTeam"})[1].text.encode('utf8').lstrip().rstrip()
|
||||||
else:
|
else:
|
||||||
matchObj['team1'] = None
|
matchObj['team1'] = None
|
||||||
matchObj['team2'] = None
|
matchObj['team2'] = None
|
||||||
|
@ -283,4 +280,3 @@ if __name__ == "__main__":
|
||||||
pp.pprint('get_results_by_date')
|
pp.pprint('get_results_by_date')
|
||||||
today_iso = datetime.datetime.today().isoformat().split('T')[0]
|
today_iso = datetime.datetime.today().isoformat().split('T')[0]
|
||||||
pp.pprint(get_results_by_date(today_iso, today_iso))
|
pp.pprint(get_results_by_date(today_iso, today_iso))
|
||||||
|
|
Loading…
Add table
Reference in a new issue