akimerslys / hltv-async-api

Fully Asynchronous modern hltv.org scraper 🌟
https://pypi.org/project/hltv-async-api/
MIT License
3 stars 0 forks source link

hltv-async-api an unofficial asynchronous HLTV API Wrapper for Python.

IMPORTANT

From today Im starting to write a Selenium based parser

I have a lot of other stuff irl, so gonna release an update on the end of Sep - Mid Nov with stats based methods. Also I have designed a live score scraper with socket.io, need a lot of time to release a first stable ver, ill be in touch after 1.0.0 (Selenium upd) of hltv-async-api (gonna rename it).

Dont forget to star a repo.

Future

Features


Installation

pip install hltv-async-api

Simple Usage


    from hltv_async_api import Hltv

    async def main():
      async with Hltv() as hltv:
        print(await hltv.get_event_info(7148, 'PGL CS2 Major Copenhagen2024'))

    if __name__ == '__main__':
      import asyncio
      asyncio.run(main())

Synchronus Usage (Beta)

For high perfomance usage recommended to use async version, it's 5x faster, and more stable.


    from hltv_async_api.sync import Hltv

    hltv = Hltv()

    print(hltv.get_event_info(7148, 'PGL CS2 Major Copenhagen2024'))

Configs

  [DEBUG] Random delay 9.55s 
  [DEBUG] Trying connect to https://www.hltv.org/matches, try 3/10
  [DEBUG] Random delay 3.9s 
  [DEBUG] Trying connect to https://www.hltv.org/matches, try 4/10

Proxy Usage

Load Proxies from list

```
proxy_list = ['http://120.234.203.171:9002', 'http://110.38.68.38:80']

hltv = Hltv(proxy_list=proxy_list)

```

Load Proxies from file

```
hltv = Hltv(proxy_path='PATH_TO_PROXY.TXT')
```

Remove proxy

Removes bad proxies

```
hltv = Hltv(proxy_path='PATH_TO_PROXY.TXT', remove_proxy=True)
```

Protocol usage

```
proxy_list = ['120.234.203.171:9002', '110.38.68.38:80']

hltv = Hltv(proxy_list=proxy_list, proxy_protocol='http')
```

Methods


Examples

Simple Example

from hltv_async_api import Hltv

async def test():

    async with Hltv() as hltv:
      print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))

if __name__ == "__main__":
    asyncio.run(test())

Proxy Parser

from hltv_async_api import Hltv

async def test():

    hltv = Hltv(debug=True, proxy_path='proxy_test.txt', timeout=1, remove_proxy=True, proxy_protocol='http')

    print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))

if __name__ == "__main__":
    asyncio.run(test())

Automatic parser with arq and redis

Tests:

To test library you can use temporarily test file


Parsed 208 matches.(97s) ERRORS: 0/208
Parsed 25 events.(23s) ERRORS: 0/25
Parsed 31 teams.(41s) ERRORS: 0/31
Parsed 31 players.(28s) ERRORS: 0/31
ERRORS=0
SUCCESS=284
Total parsed=284
Total time 96.8368

Beta / Unreleased

from hltv_async_api.beta import Beta

Requirements:

Python 3.9+

License: HLTV Async is licensed under the MIT License, allowing for personal and commercial use with minimal restrictions.

Contributing

Why not ?