adding districts and location identifier to search
This commit is contained in:
parent
4c40462bb8
commit
ec86b572b3
2 changed files with 52 additions and 14 deletions
|
|
@ -17,14 +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"
|
||||
|
||||
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):
|
||||
|
|
@ -48,19 +49,19 @@ def listing_query(
|
|||
radius: float,
|
||||
min_price: int,
|
||||
max_price: int,
|
||||
location_id: str = "STATION^5168", # kings cross station
|
||||
mustNewHome: bool = False,
|
||||
max_days_since_added: int = None,
|
||||
property_type: List['PropertyType'] = []
|
||||
property_type: List["PropertyType"] = [],
|
||||
) -> dict:
|
||||
params = {
|
||||
"locationIdentifier": "POSTCODE^4228216",
|
||||
"locationIdentifier": location_id,
|
||||
"channel": "BUY",
|
||||
"page": str(page),
|
||||
"numberOfPropertiesPerPage": "25",
|
||||
"numberOfPropertiesPerPage": "100",
|
||||
"radius": str(radius),
|
||||
"sortBy": "distance",
|
||||
"includeUnavailableProperties": "false",
|
||||
"propertyTypes": "flat",
|
||||
"dontShow": "sharedOwnership,retirement",
|
||||
"minPrice": str(min_price),
|
||||
"maxPrice": str(max_price),
|
||||
|
|
@ -70,7 +71,7 @@ def listing_query(
|
|||
"appVersion": "3.70.0",
|
||||
}
|
||||
if len(property_type) > 0:
|
||||
params['propertyTypes'] = ','.join(property_type)
|
||||
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])
|
||||
|
|
@ -78,7 +79,7 @@ def listing_query(
|
|||
|
||||
if mustNewHome:
|
||||
params["mustHave"] = "newHome"
|
||||
|
||||
print(params)
|
||||
response = requests.get(
|
||||
"https://api.rightmove.co.uk/api/property-listing",
|
||||
params=params,
|
||||
|
|
@ -111,3 +112,4 @@ if __name__ == "__main__":
|
|||
lon=d["longitude"],
|
||||
)
|
||||
rl.save()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue