adding musthave and lastXdays
This commit is contained in:
parent
36258d877f
commit
a9b8d4d630
3 changed files with 9 additions and 18 deletions
|
|
@ -16,6 +16,7 @@ params = {
|
|||
'sortBy': 'distance',
|
||||
'includeUnavailableProperties': 'false',
|
||||
'propertyTypes': 'flat',
|
||||
'mustHave': 'newHome', # added manually later
|
||||
'dontShow': 'sharedOwnership,retirement',
|
||||
'minPrice': '150000',
|
||||
'maxPrice': '500000',
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
def nextMonday():
|
||||
"""
|
||||
I think this function doesnt work when the day is monday itself.
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
now = datetime.now(timezone.utc)
|
||||
days_until_monday = (0 - now.weekday() + 7) % 7
|
||||
monday = now + timedelta(days=days_until_monday)
|
||||
monday_9am = monday.replace(hour=9, minute=0, second=0, microsecond=0, tzinfo=timezone.utc)
|
||||
return monday_9am
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(nextMonday())
|
||||
|
|
@ -30,7 +30,7 @@ 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) -> 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",
|
||||
|
|
@ -48,6 +48,13 @@ def listing_query(page: int, min_bedrooms: int, max_bedrooms: int, radius: float
|
|||
"apiApplication": "ANDROID",
|
||||
"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 mustNewHome:
|
||||
params['mustHave'] = 'newHome'
|
||||
|
||||
response = requests.get(
|
||||
"https://api.rightmove.co.uk/api/property-listing",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue