add cli param for querying properties to rent
example: python main.py --data-dir data/rs2 dump-listings --max-price 3500 --min-bedrooms 2 --max-bedrooms 4 --district islington -t rent
This commit is contained in:
parent
bb9afc76fe
commit
df24c2c1b7
3 changed files with 44 additions and 18 deletions
|
|
@ -1,12 +1,13 @@
|
|||
from dataclasses import dataclass
|
||||
import pathlib
|
||||
from rec.query import listing_query
|
||||
from rec.query import ListingType, listing_query
|
||||
from rec.districts import get_districts
|
||||
from data_access import Listing
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class QueryParameters:
|
||||
listing_type: ListingType
|
||||
min_bedrooms: int
|
||||
max_bedrooms: int
|
||||
min_price: int
|
||||
|
|
@ -32,8 +33,9 @@ def dump_listings(
|
|||
print("#### District:", district)
|
||||
for i in [1, 2]:
|
||||
try:
|
||||
d = listing_query(
|
||||
response_json = listing_query(
|
||||
page=i,
|
||||
channel=parameters.listing_type,
|
||||
min_bedrooms=parameters.min_bedrooms,
|
||||
max_bedrooms=parameters.max_bedrooms,
|
||||
radius=parameters.radius,
|
||||
|
|
@ -47,12 +49,12 @@ def dump_listings(
|
|||
print(e)
|
||||
break
|
||||
if i == 1:
|
||||
print("totalAvailableResults: ", d["totalAvailableResults"])
|
||||
if len(d["properties"]) == 0:
|
||||
print("totalAvailableResults: ", response_json["totalAvailableResults"])
|
||||
if len(response_json["properties"]) == 0:
|
||||
break
|
||||
print(f"page {i}", end=", ", flush=True)
|
||||
|
||||
for property in d["properties"]:
|
||||
for property in response_json["properties"]:
|
||||
identifier = property["identifier"]
|
||||
|
||||
listing = Listing(identifier, data_dir=data_dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue