-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
22 lines (19 loc) · 836 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import asyncio
from requests_html import AsyncHTMLSession
import time
async def fetch_html(url):
session = AsyncHTMLSession()
try:
start_time = time.time() # Enregistrer le temps de début
response = await session.get(url)
response.raise_for_status() # Raise an exception for unsuccessful requests
end_time = time.time() # Enregistrer le temps de fin
print("Temps d'exécution de fetch_html:", end_time - start_time, "secondes") # Calculer et afficher le temps d'exécution
return response.text
except Exception as e:
print(f"Error fetching the URL: {e}")
return ""
async def main():
url = "https://www.forebet.com/fr/previsions-de-football/match-center/liverpool-nottingham-forest-1920214"
html_code = await fetch_html(url)
asyncio.run(main())