add filter for furnished/unfurnished type for rented listings

This commit is contained in:
Viktor Barzin 2025-05-18 17:22:48 +00:00
parent b873eaf203
commit 9f3e466b23
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
3 changed files with 41 additions and 16 deletions

View file

@ -1,6 +1,6 @@
# from diskcache import Cache
import enum
from typing import Any, List
from typing import Any
import aiohttp
import requests
import urllib3
@ -13,6 +13,12 @@ class ListingType(enum.StrEnum):
RENT = "RENT"
class FurnishType(enum.StrEnum):
FURNISHED = "furnished"
UNFURNISHED = "unfurnished"
PART_FURNISHED = "partFurnished"
headers = {
"Host": "api.rightmove.co.uk",
# 'Accept-Encoding': 'gzip, deflate, br',
@ -48,6 +54,7 @@ async def detail_query(detail_id: int):
async def listing_query(
*,
page: int,
channel: ListingType,
min_bedrooms: int,
@ -58,8 +65,9 @@ async def listing_query(
location_id: str = "STATION^5168", # kings cross station
mustNewHome: bool = False,
max_days_since_added: int = 30,
property_type: List["PropertyType"] = [],
property_type: list[PropertyType] = [],
page_size: int = 25,
furnish_types: list[FurnishType] = [],
) -> dict[str, Any]:
params: dict[str, str] = {
"locationIdentifier": location_id,
@ -88,6 +96,9 @@ async def listing_query(
if mustNewHome:
params["mustHave"] = "newHome"
if channel is ListingType.RENT:
if furnish_types:
params["furnishTypes"] = ",".join(furnish_types)
headers = {
"Host": "api.rightmove.co.uk",