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
|
|
@ -5,6 +5,7 @@ import importlib
|
|||
from rec.districts import get_districts
|
||||
from data_access import Listing
|
||||
import csv_exporter
|
||||
from rec.query import ListingType
|
||||
|
||||
dump_listings_module = importlib.import_module('1_dump_listings')
|
||||
dump_detail_module = importlib.import_module('2_dump_detail')
|
||||
|
|
@ -41,6 +42,16 @@ def cli(ctx, data_dir: str):
|
|||
|
||||
|
||||
@cli.command()
|
||||
@click.option(
|
||||
'--type',
|
||||
'-t',
|
||||
help='Type of listing to scrape',
|
||||
type=click.Choice(
|
||||
ListingType.__members__.keys(),
|
||||
case_sensitive=False,
|
||||
),
|
||||
required=True,
|
||||
)
|
||||
@click.option(
|
||||
'--min-bedrooms',
|
||||
default=1,
|
||||
|
|
@ -80,9 +91,11 @@ def dump_listings(
|
|||
max_bedrooms: int,
|
||||
min_price: int,
|
||||
max_price: int,
|
||||
type: str,
|
||||
):
|
||||
data_dir: str = ctx.obj['data_dir']
|
||||
query_parameters = dump_listings_module.QueryParameters(
|
||||
listing_type=ListingType[type],
|
||||
district_names=set(district),
|
||||
min_bedrooms=min_bedrooms,
|
||||
max_bedrooms=max_bedrooms,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue