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
36
crawler/rec/districts.py
Normal file
36
crawler/rec/districts.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
def get_districts():
|
||||||
|
return {
|
||||||
|
"City of London": "REGION^61224",
|
||||||
|
"Greenwich": "REGION^61226",
|
||||||
|
"Hillingdon": "REGION^93959",
|
||||||
|
"Ealing": "REGION^93947",
|
||||||
|
"Richmond upon Thames": "REGION^61415",
|
||||||
|
"Sutton": "REGION^93974",
|
||||||
|
"Wandsworth": "REGION^93977",
|
||||||
|
"Camden": "REGION^93941",
|
||||||
|
"Enfield": "REGION^93950",
|
||||||
|
"Croydon": "REGION^93944",
|
||||||
|
"Hackney": "REGION^93953",
|
||||||
|
"Kingston upon Thames": "REGION^93968",
|
||||||
|
"Kensington and Chelsea": "REGION^61229",
|
||||||
|
"Bromley": "REGION^93938",
|
||||||
|
"Brent": "REGION^93935",
|
||||||
|
"Waltham Forest": "REGION^61232",
|
||||||
|
"Southwark": "REGION^61518",
|
||||||
|
"Harrow": "REGION^93956",
|
||||||
|
"Lewisham": "REGION^61413",
|
||||||
|
"Barnet": "REGION^93929",
|
||||||
|
"Islington": "REGION^93965",
|
||||||
|
"Haringey": "REGION^61227",
|
||||||
|
"Lambeth": "REGION^93971",
|
||||||
|
"Westminster": "REGION^93980",
|
||||||
|
"Tower Hamlets": "REGION^61417",
|
||||||
|
"Havering": "REGION^61228",
|
||||||
|
"Barking and Dagenham": "REGION^61400",
|
||||||
|
"Hammersmith and Fulham": "REGION^61407",
|
||||||
|
"Bexley": "REGION^93932",
|
||||||
|
"Redbridge": "REGION^61537",
|
||||||
|
"Newham": "REGION^61231",
|
||||||
|
"Merton": "REGION^61414",
|
||||||
|
"Hounslow": "REGION^93962",
|
||||||
|
}
|
||||||
|
|
@ -17,14 +17,15 @@ headers = {
|
||||||
"Connection": "close",
|
"Connection": "close",
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyType(enum.StrEnum):
|
|
||||||
BUNGALOW= "bungalow"
|
class PropertyType(enum.StrEnum):
|
||||||
DETACHED= "detached"
|
BUNGALOW = "bungalow"
|
||||||
FLAT= "flat"
|
DETACHED = "detached"
|
||||||
LAND= "land"
|
FLAT = "flat"
|
||||||
PARK_HOME= "park-home"
|
LAND = "land"
|
||||||
SEMI_DETACHED= "semi-detached"
|
PARK_HOME = "park-home"
|
||||||
TERRACED= "terraced"
|
SEMI_DETACHED = "semi-detached"
|
||||||
|
TERRACED = "terraced"
|
||||||
|
|
||||||
|
|
||||||
def detail_query(detail_id: int):
|
def detail_query(detail_id: int):
|
||||||
|
|
@ -48,19 +49,19 @@ def listing_query(
|
||||||
radius: float,
|
radius: float,
|
||||||
min_price: int,
|
min_price: int,
|
||||||
max_price: int,
|
max_price: int,
|
||||||
|
location_id: str = "STATION^5168", # kings cross station
|
||||||
mustNewHome: bool = False,
|
mustNewHome: bool = False,
|
||||||
max_days_since_added: int = None,
|
max_days_since_added: int = None,
|
||||||
property_type: List['PropertyType'] = []
|
property_type: List["PropertyType"] = [],
|
||||||
) -> dict:
|
) -> dict:
|
||||||
params = {
|
params = {
|
||||||
"locationIdentifier": "POSTCODE^4228216",
|
"locationIdentifier": location_id,
|
||||||
"channel": "BUY",
|
"channel": "BUY",
|
||||||
"page": str(page),
|
"page": str(page),
|
||||||
"numberOfPropertiesPerPage": "25",
|
"numberOfPropertiesPerPage": "100",
|
||||||
"radius": str(radius),
|
"radius": str(radius),
|
||||||
"sortBy": "distance",
|
"sortBy": "distance",
|
||||||
"includeUnavailableProperties": "false",
|
"includeUnavailableProperties": "false",
|
||||||
"propertyTypes": "flat",
|
|
||||||
"dontShow": "sharedOwnership,retirement",
|
"dontShow": "sharedOwnership,retirement",
|
||||||
"minPrice": str(min_price),
|
"minPrice": str(min_price),
|
||||||
"maxPrice": str(max_price),
|
"maxPrice": str(max_price),
|
||||||
|
|
@ -70,7 +71,7 @@ def listing_query(
|
||||||
"appVersion": "3.70.0",
|
"appVersion": "3.70.0",
|
||||||
}
|
}
|
||||||
if len(property_type) > 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:
|
||||||
if max_days_since_added not in [1, 3, 7, 14]:
|
if max_days_since_added not in [1, 3, 7, 14]:
|
||||||
raise Exception("Invalid max days. Can only be", [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:
|
if mustNewHome:
|
||||||
params["mustHave"] = "newHome"
|
params["mustHave"] = "newHome"
|
||||||
|
print(params)
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
"https://api.rightmove.co.uk/api/property-listing",
|
"https://api.rightmove.co.uk/api/property-listing",
|
||||||
params=params,
|
params=params,
|
||||||
|
|
@ -111,3 +112,4 @@ if __name__ == "__main__":
|
||||||
lon=d["longitude"],
|
lon=d["longitude"],
|
||||||
)
|
)
|
||||||
rl.save()
|
rl.save()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue