- redfin buildings support
parent
ba9fe806a7
commit
ba249ca20d
|
@ -71,7 +71,7 @@ def process_result(result: Union[Building, Property]) -> pd.DataFrame:
|
||||||
address_data = prop_data["address"]
|
address_data = prop_data["address"]
|
||||||
prop_data["site_name"] = prop_data["site_name"]
|
prop_data["site_name"] = prop_data["site_name"]
|
||||||
prop_data["listing_type"] = prop_data["listing_type"].value
|
prop_data["listing_type"] = prop_data["listing_type"].value
|
||||||
prop_data["property_type"] = prop_data["property_type"].value.lower() if prop_data["property_type"] else None
|
prop_data["property_type"] = prop_data["property_type"].value.lower() if prop_data.get("property_type") else None
|
||||||
prop_data["address_one"] = address_data.address_one
|
prop_data["address_one"] = address_data.address_one
|
||||||
prop_data["city"] = address_data.city
|
prop_data["city"] = address_data.city
|
||||||
prop_data["state"] = address_data.state
|
prop_data["state"] = address_data.state
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from ..models import Property, Address, PropertyType
|
from ..models import Property, Address, PropertyType, Building
|
||||||
from .. import Scraper
|
from .. import Scraper
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
@ -86,6 +86,34 @@ class RedfinScraper(Scraper):
|
||||||
mls_id=get_value("mlsId"),
|
mls_id=get_value("mlsId"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _parse_building(self, building: dict) -> Building:
|
||||||
|
return Building(
|
||||||
|
address=Address(
|
||||||
|
address_one=" ".join(
|
||||||
|
[
|
||||||
|
building['address']['streetNumber'],
|
||||||
|
building['address']['directionalPrefix'],
|
||||||
|
building['address']['streetName'],
|
||||||
|
building['address']['streetType'],
|
||||||
|
]
|
||||||
|
),
|
||||||
|
city=building['address']['city'],
|
||||||
|
state=building['address']['stateOrProvinceCode'],
|
||||||
|
zip_code=building['address']['postalCode'],
|
||||||
|
address_two=" ".join(
|
||||||
|
[
|
||||||
|
building['address']['unitType'],
|
||||||
|
building['address']['unitValue'],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
site_name=self.site_name,
|
||||||
|
url="https://www.redfin.com{}".format(building["url"]),
|
||||||
|
listing_type=self.listing_type,
|
||||||
|
num_units=building["numUnitsForSale"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_address(self, home_id: str):
|
def handle_address(self, home_id: str):
|
||||||
"""
|
"""
|
||||||
EPs:
|
EPs:
|
||||||
|
@ -123,5 +151,8 @@ class RedfinScraper(Scraper):
|
||||||
|
|
||||||
homes = [
|
homes = [
|
||||||
self._parse_home(home) for home in response_json["payload"]["homes"]
|
self._parse_home(home) for home in response_json["payload"]["homes"]
|
||||||
] #: support buildings
|
] + [
|
||||||
|
self._parse_building(building) for building in response_json["payload"]["buildings"].values()
|
||||||
|
]
|
||||||
|
|
||||||
return homes
|
return homes
|
||||||
|
|
Loading…
Reference in New Issue