mirror of
https://github.com/SocksPls/hltv-api
synced 2025-05-02 00:09:34 +00:00
Compare commits
2 commits
ab17ce1d30
...
9a477b3eb9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9a477b3eb9 | ||
![]() |
156c5b94e1 |
2 changed files with 9 additions and 8 deletions
13
README.md
13
README.md
|
@ -299,13 +299,14 @@ Provides an API for HLTV
|
|||
|
||||
```python
|
||||
>>> hltv.get_matches()
|
||||
[{'date': '2020-11-10',
|
||||
'time': '15:00',
|
||||
'event': b'IEM Beijing-Haidian 2020 Europe',
|
||||
'team1': b'Spirit',
|
||||
'team2': b'OG'},
|
||||
[{'date': '2022-06-06',
|
||||
'event': b'WePlay Academy League Season 4',
|
||||
'team1': b'Astralis Talent',
|
||||
'team2': b'Apeks Rebels',
|
||||
'time': '18:10',
|
||||
'url': 'https://hltv.org/matches/2356247/esl-impact-league-season-1-finals-grand-final-esl-impact-league-season-1-finals'},
|
||||
...
|
||||
}]
|
||||
]
|
||||
```
|
||||
|
||||
## `get_results`
|
||||
|
|
4
main.py
4
main.py
|
@ -5,14 +5,14 @@ from bs4 import BeautifulSoup
|
|||
from python_utils import converters
|
||||
import time
|
||||
|
||||
def get_parsed_page(url):
|
||||
def get_parsed_page(url, delay=0.5):
|
||||
# This fixes a blocked by cloudflare error i've encountered
|
||||
headers = {
|
||||
"referer": "https://www.hltv.org/stats",
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
||||
}
|
||||
|
||||
time.sleep(0.5)
|
||||
time.sleep(delay)
|
||||
|
||||
return BeautifulSoup(requests.get(url, headers=headers).text, "lxml")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue