1
0
Fork 0
mirror of https://github.com/SocksPls/hltv-api synced 2025-04-30 07:33:09 +00:00

resolve PR to pattern

This commit is contained in:
CAíque - 2022-08-14 16:05:55 -03:00
parent 4b6cde2cf6
commit 1671d93c24

19
main.py
View file

@ -337,17 +337,23 @@ def _get_matches_by_team(table):
for row in rows[0:len(rows)]: for row in rows[0:len(rows)]:
match = {} match = {}
match['date'] = row.find( dateArr = (row.find(
"td", {"class": "date-cell"}).find("span").text "td", {"class": "date-cell"}).find("span").text).split('/')
dateTextFromArrPadded = _padIfNeeded(dateArr[2]) + "-" + _padIfNeeded(dateArr[1]) + "-" + _padIfNeeded(dateArr[0])
dateFromHLTV = datetime.datetime.strptime(dateTextFromArrPadded,'%Y-%m-%d').replace(tzinfo=HLTV_ZONEINFO)
dateFromHLTV = dateFromHLTV.astimezone(LOCAL_ZONEINFO)
date = dateFromHLTV.strftime('%Y-%m-%d')
match['date'] = date
match['teams'] = {} match['teams'] = {}
match['teams']["team_1"] = row.find( match['teams']["team_1"] = row.find(
"td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"}).text "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"}).text
match['teams']["team_1_id"] = row.find( match['teams']["team_1_id"] = _findTeamId(row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"}).text)
"td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"})['href'].split('/')[2]
match['teams']["team_2"] = row.find( match['teams']["team_2"] = row.find(
"td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"}).text "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"}).text
match['teams']["team_2_id"] = row.find( match['teams']["team_2_id"] = _findTeamId(row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"}).text)
"td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"})['href'].split('/')[2]
match["confront_name"] = match['teams']["team_1"] + \ match["confront_name"] = match['teams']["team_1"] + \
" X " + match['teams']["team_2"] " X " + match['teams']["team_2"]
match["championship"] = event_name match["championship"] = event_name
@ -355,7 +361,6 @@ def _get_matches_by_team(table):
"td", {"class": "matchpage-button-cell"}).find("a")['href'] "td", {"class": "matchpage-button-cell"}).find("a")['href']
match['time'] = get_parsed_page("https://www.hltv.org" + match_url).find( match['time'] = get_parsed_page("https://www.hltv.org" + match_url).find(
'div', {"class": "timeAndEvent"}).find('div', {"class": "time"}).text 'div', {"class": "timeAndEvent"}).find('div', {"class": "time"}).text
match['full_time'] = match['date'] + ' at ' + match['time']
matches.append(match) matches.append(match)
return matches return matches