adding property type

This commit is contained in:
Kadir 2024-03-25 20:58:35 +00:00
parent d777558b34
commit 4c40462bb8
2 changed files with 80 additions and 2 deletions

View file

@ -1,4 +1,6 @@
# from diskcache import Cache
import enum
from typing import List
import requests
# from rec.db import RightmoveListing
@ -15,6 +17,15 @@ headers = {
"Connection": "close",
}
class PropertyType(enum.StrEnum):
BUNGALOW= "bungalow"
DETACHED= "detached"
FLAT= "flat"
LAND= "land"
PARK_HOME= "park-home"
SEMI_DETACHED= "semi-detached"
TERRACED= "terraced"
def detail_query(detail_id: int):
params = {
@ -39,6 +50,7 @@ def listing_query(
max_price: int,
mustNewHome: bool = False,
max_days_since_added: int = None,
property_type: List['PropertyType'] = []
) -> dict:
params = {
"locationIdentifier": "POSTCODE^4228216",
@ -57,6 +69,8 @@ def listing_query(
"apiApplication": "ANDROID",
"appVersion": "3.70.0",
}
if len(property_type) > 0:
params['propertyTypes'] = ','.join(property_type)
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])