mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-07 21:14:30 -08:00
feat: add pandas
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from ..models import Property, Address
|
||||
from ..models import Property, Address, PropertyType
|
||||
from .. import Scraper
|
||||
from typing import Any
|
||||
|
||||
@@ -7,6 +7,7 @@ from typing import Any
|
||||
class RedfinScraper(Scraper):
|
||||
def __init__(self, scraper_input):
|
||||
super().__init__(scraper_input)
|
||||
self.listing_type = scraper_input.listing_type
|
||||
|
||||
def _handle_location(self):
|
||||
url = "https://www.redfin.com/stingray/do/location-autocomplete?v=2&al=1&location={}".format(
|
||||
@@ -31,8 +32,7 @@ class RedfinScraper(Scraper):
|
||||
|
||||
return target["id"].split("_")[1], get_region_type(target["type"])
|
||||
|
||||
@staticmethod
|
||||
def _parse_home(home: dict, single_search: bool = False) -> Property:
|
||||
def _parse_home(self, home: dict, single_search: bool = False) -> Property:
|
||||
def get_value(key: str) -> Any | None:
|
||||
if key in home and "value" in home[key]:
|
||||
return home[key]["value"]
|
||||
@@ -53,10 +53,12 @@ class RedfinScraper(Scraper):
|
||||
state=home["state"],
|
||||
zip_code=home["zip"],
|
||||
)
|
||||
|
||||
url = "https://www.redfin.com{}".format(home["url"])
|
||||
property_type = home["propertyType"] if "propertyType" in home else None
|
||||
|
||||
return Property(
|
||||
site_name=self.site_name,
|
||||
listing_type=self.listing_type,
|
||||
address=address,
|
||||
url=url,
|
||||
beds=home["beds"] if "beds" in home else None,
|
||||
@@ -68,6 +70,8 @@ class RedfinScraper(Scraper):
|
||||
if not single_search
|
||||
else home["yearBuilt"],
|
||||
square_feet=get_value("sqFt"),
|
||||
lot_size=home.get("lotSize", {}).get("value", None),
|
||||
property_type=PropertyType.from_int_code(home.get("propertyType")),
|
||||
price_per_square_foot=get_value("pricePerSqFt"),
|
||||
price=get_value("price"),
|
||||
mls_id=get_value("mlsId"),
|
||||
|
||||
Reference in New Issue
Block a user