ruff format
This commit is contained in:
parent
37e3e8ad6f
commit
d777558b34
17 changed files with 411 additions and 368 deletions
|
|
@ -18,10 +18,10 @@ headers = {
|
|||
|
||||
def detail_query(detail_id: int):
|
||||
params = {
|
||||
'apiApplication': 'ANDROID',
|
||||
'appVersion': '3.70.0',
|
||||
"apiApplication": "ANDROID",
|
||||
"appVersion": "3.70.0",
|
||||
}
|
||||
url = f'https://api.rightmove.co.uk/api/property/{detail_id}'
|
||||
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("Failed due to: ", response.text)
|
||||
|
|
@ -30,7 +30,16 @@ def detail_query(detail_id: int):
|
|||
|
||||
|
||||
# @cache.memoize()
|
||||
def listing_query(page: int, min_bedrooms: int, max_bedrooms: int, radius: float, min_price: int, max_price: int, mustNewHome: bool = False, max_days_since_added: int = None) -> dict:
|
||||
def listing_query(
|
||||
page: int,
|
||||
min_bedrooms: int,
|
||||
max_bedrooms: int,
|
||||
radius: float,
|
||||
min_price: int,
|
||||
max_price: int,
|
||||
mustNewHome: bool = False,
|
||||
max_days_since_added: int = None,
|
||||
) -> dict:
|
||||
params = {
|
||||
"locationIdentifier": "POSTCODE^4228216",
|
||||
"channel": "BUY",
|
||||
|
|
@ -49,12 +58,12 @@ def listing_query(page: int, min_bedrooms: int, max_bedrooms: int, radius: float
|
|||
"appVersion": "3.70.0",
|
||||
}
|
||||
if max_days_since_added:
|
||||
if max_days_since_added not in [1,3,7,14]:
|
||||
raise Exception("Invalid max days. Can only be", [1,3,7,14])
|
||||
params['maxDaysSinceAdded'] = max_days_since_added
|
||||
|
||||
if max_days_since_added not in [1, 3, 7, 14]:
|
||||
raise Exception("Invalid max days. Can only be", [1, 3, 7, 14])
|
||||
params["maxDaysSinceAdded"] = max_days_since_added
|
||||
|
||||
if mustNewHome:
|
||||
params['mustHave'] = 'newHome'
|
||||
params["mustHave"] = "newHome"
|
||||
|
||||
response = requests.get(
|
||||
"https://api.rightmove.co.uk/api/property-listing",
|
||||
|
|
@ -69,7 +78,14 @@ def listing_query(page: int, min_bedrooms: int, max_bedrooms: int, radius: float
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
response = listing_query(page=1, min_bedrooms=2, max_bedrooms=2, radius=5.0, min_price=150000, max_price=700000)
|
||||
response = listing_query(
|
||||
page=1,
|
||||
min_bedrooms=2,
|
||||
max_bedrooms=2,
|
||||
radius=5.0,
|
||||
min_price=150000,
|
||||
max_price=700000,
|
||||
)
|
||||
resp = response
|
||||
for d in resp["properties"]:
|
||||
rl = RightmoveListing(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue