From 8f90a80b0a3adcb5adbe61546835a1202883c4b2 Mon Sep 17 00:00:00 2001 From: Zachary Hampton <69336300+ZacharyHampton@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:22:47 -0700 Subject: [PATCH] - lat lon on realtor & redfin --- homeharvest/core/scrapers/realtor/__init__.py | 6 ++++++ homeharvest/core/scrapers/redfin/__init__.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/homeharvest/core/scrapers/realtor/__init__.py b/homeharvest/core/scrapers/realtor/__init__.py index 5298c3a..0ee873e 100644 --- a/homeharvest/core/scrapers/realtor/__init__.py +++ b/homeharvest/core/scrapers/realtor/__init__.py @@ -195,6 +195,10 @@ class RealtorScraper(Scraper): street_post_direction street_suffix unit + coordinate { + lon + lat + } } } list_price @@ -245,6 +249,8 @@ class RealtorScraper(Scraper): unit=parse_unit(result["location"]["address"]["unit"]), country="USA", ), + latitude=result["location"]["address"]["coordinate"]["lat"], + longitude=result["location"]["address"]["coordinate"]["lon"], site_name=self.site_name, property_url="https://www.realtor.com/realestateandhomes-detail/" + result["property_id"], diff --git a/homeharvest/core/scrapers/redfin/__init__.py b/homeharvest/core/scrapers/redfin/__init__.py index 392855a..a3e9e18 100644 --- a/homeharvest/core/scrapers/redfin/__init__.py +++ b/homeharvest/core/scrapers/redfin/__init__.py @@ -52,7 +52,6 @@ class RedfinScraper(Scraper): else: address_info = home["streetAddress"] street_address, unit = parse_address_two(address_info["assembledAddress"]) - unit = parse_address_two(address_info["assembledAddress"]) address = Address( street_address=street_address, @@ -62,9 +61,11 @@ class RedfinScraper(Scraper): unit=unit, country="USA", ) + url = "https://www.redfin.com{}".format(home["url"]) - property_type = home["propertyType"] if "propertyType" in home else None + #: property_type = home["propertyType"] if "propertyType" in home else None lot_size_data = home.get("lotSize") + if not isinstance(lot_size_data, int): lot_size = ( lot_size_data.get("value", None) @@ -93,6 +94,8 @@ class RedfinScraper(Scraper): price_per_sqft=get_value("pricePerSqFt"), price=get_value("price"), mls_id=get_value("mlsId"), + latitude=home["latLong"]["latitude"] if "latLong" in home else None, + longitude=home["latLong"]["longitude"] if "latLong" in home else None, ) def _parse_building(self, building: dict) -> Property: