Skip to main content

Version License: MIT

Hi, I analyze hltv.org as a part of my pet project. This parser can help you build a prematch analytics dataset with data from Team stats and Analytics pages.

Install

pip install hltv-stats

Usage

HLTVMatch provides public methods for Analytics, use filename parameter to save data to a file.

from hltv_stats import HLTVMatch
match_url = "/matches/2361342/natus-vincere-vs-outsiders-iem-katowice-2023"
match = HLTVMatch(match_url)
match.parse_analytics_summary(filename=None)
Response:

[{'team': 'natus-vincere',
  'indicator': 'plus',
  'insight': 'natus vincere has better form ranking',
  'match_id': '2361342'},
    ...
]
match.parse_head_to_head()
Response:

[{'player_team': 'natus-vincere',
  'player_nickname': 's1mple',
  'table_3_months': '1.13',
  'table_event': '1.17',
  'match_id': '2361342'},
    ...
]
match.parse_pick_ban_stats()
Response:

[{'analytics_map_name': 'mirage',
  'team': 'natus-vincere',
  'analytics_map_stats_pick_percentage': '39%',
  'analytics_map_stats_ban_percentage': '0%',
  'analytics_map_stats_win_percentage': '29%',
  'analytics_map_stats_played': '7',
  'analytics_map_stats_comment': 'First pick',
  'match_id': '2361342'},
    ...
]

match.parse_analytics_center() method combines all above methods and returns a tuple of lists.

HLTVTeam provides public methods for parsing Team stats page, with filtering by time using time_filter parameter, use filename parameter to save data to a file.

from hltv_stats import HLTVTeam
team = HLTVTeam("/4608/natus-vincere")
#You can use match_id to assign team's current state(statistic) to specific match
#this will add match_id field to all json files
team.match_id = match.match_id
#time_filter: 3 - last 3 months, 6 - last 6 months, 0 - all time, ...
team.parse_matches(time_filter=1) #returns list of played matches in json format
team.parse_players(time_filter=1) #returns list of team players' statistics in json format
team.parse_maps(time_filter=1) #returns maps statistics in json format
team.parse_events(time_filter=1) #returns events statistics in json format

team.parse_all_stats(time_filter=1)

.parse_all_stats(time_filter=1) method combines all above methods and returns a tuple of lists.

parse_upcoming_matches() method parses all upcoming matches from Match page.

#Parse upcoming matches and save to json files
#:param months: list of months to parse, i.e. [1,3] <=> [last month, last 3 months]
#:param with_teams: bool, if True, parse teams' statistic as well

from hltv_stats import parse_upcoming_matches
parse_upcoming_matches(months=[1], with_teams=True)
Result folder tree contains json files with all match data, and team data if with_teams=True.
.
├── configs - contains 2 config files: which holds data about all parsed matches and teams and are used by is_parsed() method to check if match is already parsed and skips it.
├── output
│   ├── matches 
│   └── teams

Also check out example.ipynb or contact me.

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Metadata

Release files for hltv-stats 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hltv-stats 0.1.7
File Size Uploaded Provenance Actions
hltv_stats-0.1.7.tar.gz 8.7 kB Without provenance Details for hltv_stats-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hltv-stats 0.1.7
File Interpreter ABI Platform Actions
hltv_stats-0.1.7-py3-none-any.whl Python 3 none any Details for hltv_stats-0.1.7-py3-none-any.whl

Total release size: 17.3 kB

Release files / hltv_stats-0.1.7.tar.gz

Download URL hltv_stats-0.1.7.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0a86f2eb43b08ffce00a75fc4c924898fd47d34252bf6eb272673ce486425fa3
BLAKE2b-256 checksum
How to use checksums
a1cb9a06eec4265555d373f2eb874f6c00ac77ad6ab0bc3934c716be1f0aef07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.9.12 Darwin/21.6.0

Release files / hltv_stats-0.1.7-py3-none-any.whl

Download URL hltv_stats-0.1.7-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25335c70357edbfc8fd5cf8b631ecfcc6d8cb1471f79591770a5cae0517b0dff
BLAKE2b-256 checksum
How to use checksums
6cfd883af5aa8b4388b7d95357d5ad0c2e7bdf335c3c6f7d2abb4c74bcb6f821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.9.12 Darwin/21.6.0

Security for hltv-stats 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page