use aiohttp to fetch details concurrently
This commit is contained in:
parent
61b8c82592
commit
01ac24b4b7
5 changed files with 602 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# from diskcache import Cache
|
||||
import enum
|
||||
from typing import List
|
||||
import aiohttp
|
||||
import requests
|
||||
import urllib3
|
||||
|
||||
|
|
@ -36,14 +37,14 @@ async def detail_query(detail_id: int):
|
|||
"appVersion": "3.70.0",
|
||||
}
|
||||
url = f"https://api.rightmove.co.uk/api/property/{detail_id}"
|
||||
response = requests.get(url, params=params, headers=headers, verify=False)
|
||||
if response.status_code != 200:
|
||||
raise Exception(
|
||||
f"""id: {detail_id}. Status Code: {response.status_code}."""
|
||||
f"""Failed due to: {response.text}"""
|
||||
)
|
||||
|
||||
return response.json()
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, params=params, headers=headers) as response:
|
||||
if response.status != 200:
|
||||
raise Exception(
|
||||
f"""id: {detail_id}. Status Code: {response.status}."""
|
||||
f"""Failed due to: {await response.text()}"""
|
||||
)
|
||||
return await response.json()
|
||||
|
||||
|
||||
async def listing_query(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue