mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-05 12:04:31 -08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
803fd618e9 | ||
|
|
b23b55ca80 |
@@ -53,7 +53,9 @@ def scrape_property(
|
||||
if not properties_dfs:
|
||||
return pd.DataFrame()
|
||||
|
||||
properties_dfs = [df for df in properties_dfs if not df.empty]
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", category=FutureWarning)
|
||||
|
||||
return pd.concat(properties_dfs, ignore_index=True, axis=0)[ordered_properties].replace({"None": "", None: ""})
|
||||
return pd.concat(properties_dfs, ignore_index=True, axis=0)[ordered_properties].replace({"None": pd.NA, None: pd.NA, "": pd.NA})
|
||||
|
||||
@@ -36,6 +36,7 @@ class PropertyType(Enum):
|
||||
CONDO_TOWNHOME = "CONDO_TOWNHOME"
|
||||
CONDO_TOWNHOME_ROWHOME_COOP = "CONDO_TOWNHOME_ROWHOME_COOP"
|
||||
CONDO = "CONDO"
|
||||
CONDOP = "CONDOP"
|
||||
CONDOS = "CONDOS"
|
||||
COOP = "COOP"
|
||||
DUPLEX_TRIPLEX = "DUPLEX_TRIPLEX"
|
||||
@@ -52,6 +53,7 @@ class PropertyType(Enum):
|
||||
|
||||
@dataclass
|
||||
class Address:
|
||||
full_line: str | None = None
|
||||
street: str | None = None
|
||||
unit: str | None = None
|
||||
city: str | None = None
|
||||
|
||||
@@ -52,6 +52,7 @@ class RealtorScraper(Scraper):
|
||||
listing_id
|
||||
}
|
||||
address {
|
||||
line
|
||||
street_direction
|
||||
street_number
|
||||
street_name
|
||||
@@ -236,6 +237,7 @@ class RealtorScraper(Scraper):
|
||||
stories
|
||||
}
|
||||
address {
|
||||
line
|
||||
street_direction
|
||||
street_number
|
||||
street_name
|
||||
@@ -352,6 +354,7 @@ class RealtorScraper(Scraper):
|
||||
street_number
|
||||
street_name
|
||||
street_suffix
|
||||
line
|
||||
unit
|
||||
city
|
||||
state_code
|
||||
@@ -657,6 +660,8 @@ class RealtorScraper(Scraper):
|
||||
if not self.extra_property_data:
|
||||
return {}
|
||||
|
||||
#: TODO: migrate "advertisers" and "estimates" to general query
|
||||
|
||||
query = """query GetHome($property_id: ID!) {
|
||||
home(property_id: $property_id) {
|
||||
__typename
|
||||
@@ -765,6 +770,7 @@ class RealtorScraper(Scraper):
|
||||
address = result["address"]
|
||||
|
||||
return Address(
|
||||
full_line=address.get("line"),
|
||||
street=" ".join(
|
||||
part for part in [
|
||||
address.get("street_number"),
|
||||
@@ -800,7 +806,7 @@ class RealtorScraper(Scraper):
|
||||
return Description(
|
||||
primary_photo=primary_photo,
|
||||
alt_photos=RealtorScraper.process_alt_photos(result.get("photos")),
|
||||
style=PropertyType(style) if style else None,
|
||||
style=PropertyType.__getitem__(style) if style and style in PropertyType.__members__ else None,
|
||||
beds=description_data.get("beds"),
|
||||
baths_full=description_data.get("baths_full"),
|
||||
baths_half=description_data.get("baths_half"),
|
||||
|
||||
@@ -10,6 +10,7 @@ ordered_properties = [
|
||||
"status",
|
||||
"text",
|
||||
"style",
|
||||
"full_street_line",
|
||||
"street",
|
||||
"unit",
|
||||
"city",
|
||||
@@ -55,6 +56,7 @@ def process_result(result: Property) -> pd.DataFrame:
|
||||
|
||||
if "address" in prop_data:
|
||||
address_data = prop_data["address"]
|
||||
prop_data["full_street_line"] = address_data.full_line
|
||||
prop_data["street"] = address_data.street
|
||||
prop_data["unit"] = address_data.unit
|
||||
prop_data["city"] = address_data.city
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "homeharvest"
|
||||
version = "0.3.22"
|
||||
version = "0.3.24"
|
||||
description = "Real estate scraping library"
|
||||
authors = ["Zachary Hampton <zachary@bunsly.com>", "Cullen Watson <cullen@bunsly.com>"]
|
||||
homepage = "https://github.com/Bunsly/HomeHarvest"
|
||||
|
||||
@@ -156,3 +156,12 @@ def test_realtor_without_extra_details():
|
||||
]
|
||||
|
||||
assert results[0] != results[1]
|
||||
|
||||
|
||||
def test_pr_zip_code():
|
||||
results = scrape_property(
|
||||
location="00741",
|
||||
listing_type="for_sale",
|
||||
)
|
||||
|
||||
assert results is not None and len(results) > 0
|
||||
|
||||
Reference in New Issue
Block a user