mirror of
https://github.com/SocksPls/hltv-api
synced 2025-04-30 07:33:09 +00:00
get_match_info
This commit is contained in:
parent
cfbd69375f
commit
ae8333d43b
2 changed files with 150 additions and 0 deletions
110
README.md
110
README.md
|
@ -185,6 +185,116 @@ Provides an API for HLTV
|
||||||
b'K/D Ratio': b'1.05'}}
|
b'K/D Ratio': b'1.05'}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `get_match_info`
|
||||||
|
```python
|
||||||
|
>>> get_match_info("77841")
|
||||||
|
{'team1': {'name': 'Astralis',
|
||||||
|
'players': ['device', 'Magisk', 'Xyp9x', 'dupreeh', 'gla1ve'],
|
||||||
|
'device': {'kills': '67',
|
||||||
|
'headshots': '23',
|
||||||
|
'assists': '17',
|
||||||
|
'flash_assists': '7',
|
||||||
|
'deaths': '61',
|
||||||
|
'kast': '71.9%',
|
||||||
|
'kd_diff': '+6',
|
||||||
|
'adr': '84.8',
|
||||||
|
'fk_diff': '+7',
|
||||||
|
'rating': '1.17'},
|
||||||
|
'Magisk': {'kills': '59',
|
||||||
|
'headshots': '25',
|
||||||
|
'assists': '12',
|
||||||
|
'flash_assists': '3',
|
||||||
|
'deaths': '64',
|
||||||
|
'kast': '68.5%',
|
||||||
|
'kd_diff': '-5',
|
||||||
|
'adr': '77.3',
|
||||||
|
'fk_diff': '+4',
|
||||||
|
'rating': '1.03'},
|
||||||
|
'Xyp9x': {'kills': '58',
|
||||||
|
'headshots': '24',
|
||||||
|
'assists': '22',
|
||||||
|
'flash_assists': '8',
|
||||||
|
'deaths': '58',
|
||||||
|
'kast': '69.7%',
|
||||||
|
'kd_diff': '0',
|
||||||
|
'adr': '72.6',
|
||||||
|
'fk_diff': '+1',
|
||||||
|
'rating': '1.02'},
|
||||||
|
'dupreeh': {'kills': '56',
|
||||||
|
'headshots': '33',
|
||||||
|
'assists': '15',
|
||||||
|
'flash_assists': '2',
|
||||||
|
'deaths': '61',
|
||||||
|
'kast': '66.3%',
|
||||||
|
'kd_diff': '-5',
|
||||||
|
'adr': '59.7',
|
||||||
|
'fk_diff': '+1',
|
||||||
|
'rating': '0.94'},
|
||||||
|
'gla1ve': {'kills': '45',
|
||||||
|
'headshots': '19',
|
||||||
|
'assists': '22',
|
||||||
|
'flash_assists': '9',
|
||||||
|
'deaths': '65',
|
||||||
|
'kast': '60.7%',
|
||||||
|
'kd_diff': '-20',
|
||||||
|
'adr': '62.5',
|
||||||
|
'fk_diff': '-8',
|
||||||
|
'rating': '0.79'}},
|
||||||
|
'team2': {'name': 'G2',
|
||||||
|
'players': ['NiKo', 'huNter-', 'AmaNEk', 'nexa', 'kennyS'],
|
||||||
|
'NiKo': {'kills': '67',
|
||||||
|
'headshots': '23',
|
||||||
|
'assists': '17',
|
||||||
|
'flash_assists': '7',
|
||||||
|
'deaths': '61',
|
||||||
|
'kast': '71.9%',
|
||||||
|
'kd_diff': '+6',
|
||||||
|
'adr': '84.8',
|
||||||
|
'fk_diff': '+7',
|
||||||
|
'rating': '1.17'},
|
||||||
|
'huNter-': {'kills': '59',
|
||||||
|
'headshots': '25',
|
||||||
|
'assists': '12',
|
||||||
|
'flash_assists': '3',
|
||||||
|
'deaths': '64',
|
||||||
|
'kast': '68.5%',
|
||||||
|
'kd_diff': '-5',
|
||||||
|
'adr': '77.3',
|
||||||
|
'fk_diff': '+4',
|
||||||
|
'rating': '1.03'},
|
||||||
|
'AmaNEk': {'kills': '58',
|
||||||
|
'headshots': '24',
|
||||||
|
'assists': '22',
|
||||||
|
'flash_assists': '8',
|
||||||
|
'deaths': '58',
|
||||||
|
'kast': '69.7%',
|
||||||
|
'kd_diff': '0',
|
||||||
|
'adr': '72.6',
|
||||||
|
'fk_diff': '+1',
|
||||||
|
'rating': '1.02'},
|
||||||
|
'nexa': {'kills': '56',
|
||||||
|
'headshots': '33',
|
||||||
|
'assists': '15',
|
||||||
|
'flash_assists': '2',
|
||||||
|
'deaths': '61',
|
||||||
|
'kast': '66.3%',
|
||||||
|
'kd_diff': '-5',
|
||||||
|
'adr': '59.7',
|
||||||
|
'fk_diff': '+1',
|
||||||
|
'rating': '0.94'},
|
||||||
|
'kennyS': {'kills': '45',
|
||||||
|
'headshots': '19',
|
||||||
|
'assists': '22',
|
||||||
|
'flash_assists': '9',
|
||||||
|
'deaths': '65',
|
||||||
|
'kast': '60.7%',
|
||||||
|
'kd_diff': '-20',
|
||||||
|
'adr': '62.5',
|
||||||
|
'fk_diff': '-8',
|
||||||
|
'rating': '0.79'}}}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## `get_matches`
|
## `get_matches`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
40
main.py
40
main.py
|
@ -145,6 +145,46 @@ def get_team_info(teamid):
|
||||||
return team_info
|
return team_info
|
||||||
|
|
||||||
|
|
||||||
|
def get_match_info(match_id):
|
||||||
|
"""
|
||||||
|
Will get match data, NOT map data
|
||||||
|
:param match_id: integer (or string consisting of integers)
|
||||||
|
:return dictionary of match
|
||||||
|
|
||||||
|
example match id: 65090 (fnatic-vs-nip)
|
||||||
|
"""
|
||||||
|
page = get_parsed_page(f"https://www.hltv.org/stats/matches/{match_id}/a")
|
||||||
|
|
||||||
|
match_info = {
|
||||||
|
"team1": {
|
||||||
|
"name": page.find_all("table", {"class": "stats-table"})[0].find("th", {"class": "st-teamname"}).text
|
||||||
|
},
|
||||||
|
"team2": {
|
||||||
|
"name": page.find_all("table", {"class": "stats-table"})[1].find("th", {"class": "st-teamname"}).text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match_info["team1"]["players"] = [player.text for player in page.find_all("table", {"class": "stats-table"})[0].find_all("td", {"class": "st-player"})]
|
||||||
|
match_info["team2"]["players"] = [player.text for player in page.find_all("table", {"class": "stats-table"})[1].find_all("td", {"class": "st-player"})]
|
||||||
|
|
||||||
|
for team in ["team1", "team2"]:
|
||||||
|
for count, player in enumerate(match_info[team]["players"]):
|
||||||
|
stats_table = page.find_all("table", {"class": "stats-table"})[0]
|
||||||
|
match_info[team][player] = {
|
||||||
|
"kills": stats_table.find_all("td", {"class": "st-kills"})[count].text.split()[0],
|
||||||
|
"headshots": stats_table.find_all("td", {"class": "st-kills"})[count].text.split("(")[-1][:-1],
|
||||||
|
"assists": stats_table.find_all("td", {"class": "st-assists"})[count].text.split()[0],
|
||||||
|
"flash_assists": stats_table.find_all("td", {"class": "st-assists"})[count].text.split("(")[-1][:-1],
|
||||||
|
"deaths": stats_table.find_all("td", {"class": "st-deaths"})[count].text,
|
||||||
|
"kast": stats_table.find_all("td", {"class": "st-kdratio"})[count].text,
|
||||||
|
"kd_diff": stats_table.find_all("td", {"class": "st-kddiff"})[count].text,
|
||||||
|
"adr": stats_table.find_all("td", {"class": "st-adr"})[count].text,
|
||||||
|
"fk_diff": stats_table.find_all("td", {"class": "st-fkdiff"})[count].text,
|
||||||
|
"rating": stats_table.find_all("td", {"class": "st-rating"})[count].text,
|
||||||
|
}
|
||||||
|
|
||||||
|
return match_info
|
||||||
|
|
||||||
def _get_current_lineup(player_anchors):
|
def _get_current_lineup(player_anchors):
|
||||||
"""
|
"""
|
||||||
helper function for function above
|
helper function for function above
|
||||||
|
|
Loading…
Add table
Reference in a new issue