mirror of
https://github.com/SocksPls/hltv-api
synced 2025-06-28 00:19:49 +00:00
programmable delay
This commit is contained in:
parent
156c5b94e1
commit
9a477b3eb9
1 changed files with 2 additions and 2 deletions
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