mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-04 11:34:32 -08:00
Fix sold listings not included when listing_type=None (issue #142)
When listing_type=None, sold listings were excluded despite documentation stating all types should be returned. This fix includes two changes: 1. Explicitly include common listing types (for_sale, for_rent, sold, pending, off_market) when listing_type=None instead of sending empty status parameter 2. Fix or_filters logic to only apply for PENDING when not mixed with other types like SOLD, preventing unintended filtering Updated README documentation to accurately reflect that None returns common listing types rather than all 8 types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,7 @@ properties = scrape_property(
|
||||
#### Sorting & Listing Types
|
||||
```py
|
||||
# Sort options: list_price, list_date, sqft, beds, baths, last_update_date
|
||||
# Listing types: "for_sale", "for_rent", "sold", "pending", list, or None (all)
|
||||
# Listing types: "for_sale", "for_rent", "sold", "pending", "off_market", list, or None (common types)
|
||||
properties = scrape_property(
|
||||
location="Miami, FL",
|
||||
listing_type=["for_sale", "pending"], # Single string, list, or None
|
||||
@@ -158,7 +158,7 @@ Required
|
||||
│ - 'other'
|
||||
│ - 'ready_to_build'
|
||||
│ - List of strings returns properties matching ANY status: ['for_sale', 'pending']
|
||||
│ - None returns all listing types
|
||||
│ - None returns common listing types (for_sale, for_rent, sold, pending, off_market)
|
||||
│
|
||||
Optional
|
||||
├── property_type (list): Choose the type of properties.
|
||||
|
||||
@@ -144,7 +144,15 @@ class RealtorScraper(Scraper):
|
||||
# Determine date field based on listing type
|
||||
# Convert listing_type to list for uniform handling
|
||||
if self.listing_type is None:
|
||||
listing_types = []
|
||||
# When None, return all common listing types as documented
|
||||
# Note: NEW_COMMUNITY, OTHER, and READY_TO_BUILD are excluded as they typically return no results
|
||||
listing_types = [
|
||||
ListingType.FOR_SALE,
|
||||
ListingType.FOR_RENT,
|
||||
ListingType.SOLD,
|
||||
ListingType.PENDING,
|
||||
ListingType.OFF_MARKET,
|
||||
]
|
||||
date_field = None # When no listing_type is specified, skip date filtering
|
||||
elif isinstance(self.listing_type, list):
|
||||
listing_types = self.listing_type
|
||||
@@ -277,10 +285,14 @@ class RealtorScraper(Scraper):
|
||||
else:
|
||||
sort_param = "" #: prioritize normal fractal sort from realtor
|
||||
|
||||
# Handle PENDING with or_filters (applies if PENDING is in the list or is the single type)
|
||||
# Handle PENDING with or_filters
|
||||
# Only use or_filters when PENDING is the only type or mixed only with FOR_SALE
|
||||
# Using or_filters with other types (SOLD, FOR_RENT, etc.) will exclude those types
|
||||
has_pending = ListingType.PENDING in listing_types
|
||||
other_types = [lt for lt in listing_types if lt not in [ListingType.PENDING, ListingType.FOR_SALE]]
|
||||
use_or_filters = has_pending and len(other_types) == 0
|
||||
pending_or_contingent_param = (
|
||||
"or_filters: { contingent: true, pending: true }" if has_pending else ""
|
||||
"or_filters: { contingent: true, pending: true }" if use_or_filters else ""
|
||||
)
|
||||
|
||||
# Build bucket parameter (only use fractal sort if no custom sort is specified)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "homeharvest"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
description = "Real estate scraping library"
|
||||
authors = ["Zachary Hampton <zachary@bunsly.com>", "Cullen Watson <cullen@bunsly.com>"]
|
||||
homepage = "https://github.com/ZacharyHampton/HomeHarvest"
|
||||
|
||||
Reference in New Issue
Block a user