From 79b2b648f5e33baf752ae2ac9b638747a3c90c69 Mon Sep 17 00:00:00 2001 From: Zachary Hampton Date: Fri, 14 Nov 2025 13:30:54 -0800 Subject: [PATCH] Fix sold listings not included when listing_type=None (issue #142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 4 ++-- homeharvest/core/scrapers/realtor/__init__.py | 18 +++++++++++++++--- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 965f6bc..ef6bf1c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/homeharvest/core/scrapers/realtor/__init__.py b/homeharvest/core/scrapers/realtor/__init__.py index f617965..39ffbdc 100644 --- a/homeharvest/core/scrapers/realtor/__init__.py +++ b/homeharvest/core/scrapers/realtor/__init__.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 3320385..6474b82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "homeharvest" -version = "0.8.4" +version = "0.8.5" description = "Real estate scraping library" authors = ["Zachary Hampton ", "Cullen Watson "] homepage = "https://github.com/ZacharyHampton/HomeHarvest"