2023-09-18 19:02:12 -07:00
< img src = "https://github.com/ZacharyHampton/HomeHarvest/assets/78247585/d1a2bf8b-09f5-4c57-b33a-0ada8a34f12d" width = "400" >
2023-09-17 13:10:21 -07:00
2024-03-03 09:45:28 -08:00
**HomeHarvest** is a real estate scraping library that extracts and formats data in the style of MLS listings.
2023-09-15 19:47:46 -07:00
2023-09-21 09:55:29 -07:00
**Not technical?** Try out the web scraping tool on our site at [tryhomeharvest.com ](https://tryhomeharvest.com ).
2023-11-06 21:13:01 -08:00
*Looking to build a data-focused software product?* ** [Book a call ](https://bunsly.com )** *to work with us.*
2023-09-21 09:55:29 -07:00
2023-10-04 06:58:55 -07:00
## HomeHarvest Features
2023-09-18 17:35:38 -07:00
2023-10-04 06:58:55 -07:00
- **Source**: Fetches properties directly from **Realtor.com** .
- **Data Format**: Structures data to resemble MLS listings.
- **Export Flexibility**: Options to save as either CSV or Excel.
2023-09-18 21:53:10 -07:00
2023-10-05 18:24:23 -07:00
[Video Guide for HomeHarvest ](https://youtu.be/J1qgNPgmSLI ) - _updated for release v0.3.4_
2023-09-18 21:53:10 -07:00
2023-09-18 19:47:55 -07:00
![homeharvest ](https://github.com/ZacharyHampton/HomeHarvest/assets/78247585/b3d5d727-e67b-4a9f-85d8-1e65fd18620a )
2023-09-18 17:35:38 -07:00
2023-09-18 08:38:56 -07:00
## Installation
2023-09-15 19:47:46 -07:00
```bash
2024-03-03 09:49:27 -08:00
pip install -U homeharvest
2023-09-17 13:10:21 -07:00
```
2024-05-14 19:13:04 -07:00
_Python version >= [3.9](https://www.python.org/downloads/release/python-3100/) required_
2023-09-19 13:01:39 -07:00
2023-09-18 17:35:38 -07:00
## Usage
2023-09-19 13:01:39 -07:00
2023-10-04 20:12:16 -07:00
### Python
```py
from homeharvest import scrape_property
from datetime import datetime
# Generate filename based on current timestamp
current_timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"HomeHarvest_{current_timestamp}.csv"
properties = scrape_property(
location="San Diego, CA",
2023-10-05 11:43:00 -07:00
listing_type="sold", # or (for_sale, for_rent, pending)
2024-11-03 15:23:58 -08:00
property_type='single_family',
2023-11-03 16:35:41 -07:00
past_days=30, # sold in last 30 days - listed in last 30 days if (for_sale, for_rent)
2024-04-16 12:55:44 -07:00
# date_from="2023-05-01", # alternative to past_days
# date_to="2023-05-28",
2024-03-03 09:45:28 -08:00
# foreclosure=True
2023-10-04 20:12:16 -07:00
# mls_only=True, # only fetch MLS listings
)
print(f"Number of properties: {len(properties)}")
# Export to csv
properties.to_csv(filename, index=False)
print(properties.head())
```
2023-10-04 06:58:55 -07:00
## Output
2023-09-18 17:35:38 -07:00
```plaintext
2023-10-04 06:58:55 -07:00
>>> properties.head()
MLS MLS # Status Style ... COEDate LotSFApx PrcSqft Stories
0 SDCA 230018348 SOLD CONDOS ... 2023-10-03 290110 803 2
1 SDCA 230016614 SOLD TOWNHOMES ... 2023-10-03 None 838 3
2 SDCA 230016367 SOLD CONDOS ... 2023-10-03 30056 649 1
3 MRCA NDP2306335 SOLD SINGLE_FAMILY ... 2023-10-03 7519 661 2
4 SDCA 230014532 SOLD CONDOS ... 2023-10-03 None 752 1
[5 rows x 22 columns]
```
### Parameters for `scrape_property()`
```
2023-09-18 17:35:38 -07:00
Required
2023-10-04 08:11:53 -07:00
├── location (str): The address in various formats - this could be just a zip code, a full address, or city/state, etc.
2024-11-03 15:23:07 -08:00
├── listing_type (option): Choose the type of listing.
2023-10-04 08:11:53 -07:00
- 'for_rent'
- 'for_sale'
- 'sold'
2024-11-03 15:23:07 -08:00
- 'pending' (for pending/contingent sales)
2023-10-04 08:11:53 -07:00
2023-09-18 17:35:38 -07:00
Optional
2024-11-03 15:23:07 -08:00
├── property_type (list): Choose the type of properties.
- 'single_family'
- 'multi_family'
- 'condos'
- 'condo_townhome_rowhome_coop'
- 'condo_townhome'
- 'townhomes'
- 'duplex_triplex'
- 'farm'
- 'land'
- 'mobile'
2024-11-03 15:23:58 -08:00
2023-10-04 08:11:53 -07:00
├── radius (decimal): Radius in miles to find comparable properties based on individual addresses.
│ Example: 5.5 (fetches properties within a 5.5-mile radius if location is set to a specific address; otherwise, ignored)
│
2023-10-05 08:03:21 -07:00
├── past_days (integer): Number of past days to filter properties. Utilizes 'last_sold_date' for 'sold' listing types, and 'list_date' for others (for_rent, for_sale).
2023-10-04 08:11:53 -07:00
│ Example: 30 (fetches properties listed/sold in the last 30 days)
│
2023-11-03 16:52:22 -07:00
├── date_from, date_to (string): Start and end dates to filter properties listed or sold, both dates are required.
2023-11-19 23:05:10 -08:00
| (use this to get properties in chunks as there's a 10k result limit)
2024-04-16 12:55:44 -07:00
│ Format for both must be "YYYY-MM-DD".
2023-11-03 16:52:22 -07:00
│ Example: "2023-05-01", "2023-05-15" (fetches properties listed/sold between these dates)
2023-11-03 16:35:41 -07:00
│
2023-10-04 08:11:53 -07:00
├── mls_only (True/False): If set, fetches only MLS listings (mainly applicable to 'sold' listings)
│
2024-03-03 09:45:28 -08:00
├── foreclosure (True/False): If set, fetches only foreclosures
│
2024-05-31 22:17:29 -07:00
├── proxy (string): In format 'http://user:pass@host:port'
2024-05-02 09:04:49 -07:00
│
2024-08-20 05:19:15 -07:00
├── extra_property_data (True/False): Increases requests by O(n). If set, this fetches additional property data for general searches (e.g. schools, tax appraisals etc.)
2024-05-31 22:17:29 -07:00
│
2024-11-03 15:23:07 -08:00
├── exclude_pending (True/False): If set, excludes 'pending' properties from the 'for_sale' results unless listing_type is 'pending'
2024-07-15 07:19:57 -07:00
│
└── limit (integer): Limit the number of properties to fetch. Max & default is 10000.
2023-11-03 16:35:41 -07:00
```
2023-09-18 17:35:38 -07:00
### Property Schema
```plaintext
Property
├── Basic Information:
2023-10-04 19:21:45 -07:00
│ ├── property_url
2024-09-06 15:49:07 -07:00
│ ├── property_id
│ ├── listing_id
2023-10-04 19:21:45 -07:00
│ ├── mls
│ ├── mls_id
│ └── status
2023-09-18 17:35:38 -07:00
├── Address Details:
2023-10-04 08:11:53 -07:00
│ ├── street
│ ├── unit
│ ├── city
│ ├── state
2023-10-04 19:21:45 -07:00
│ └── zip_code
2023-10-04 06:58:55 -07:00
├── Property Description:
2023-10-04 08:11:53 -07:00
│ ├── style
│ ├── beds
2023-10-04 19:21:45 -07:00
│ ├── full_baths
│ ├── half_baths
2023-10-04 08:11:53 -07:00
│ ├── sqft
│ ├── year_built
2023-10-04 19:21:45 -07:00
│ ├── stories
2024-08-20 05:19:15 -07:00
│ ├── garage
2023-10-04 19:21:45 -07:00
│ └── lot_sqft
2023-10-04 06:58:55 -07:00
├── Property Listing Details:
2023-10-09 09:00:36 -07:00
│ ├── days_on_mls
2023-10-04 08:11:53 -07:00
│ ├── list_price
2024-08-13 10:44:11 -07:00
│ ├── list_price_min
│ ├── list_price_max
2023-10-04 08:11:53 -07:00
│ ├── list_date
2024-03-13 19:17:17 -07:00
│ ├── pending_date
2023-10-04 19:21:45 -07:00
│ ├── sold_price
2023-10-04 08:11:53 -07:00
│ ├── last_sold_date
2023-10-04 19:21:45 -07:00
│ ├── price_per_sqft
2024-08-20 05:19:15 -07:00
│ ├── new_construction
2023-10-04 08:11:53 -07:00
│ └── hoa_fee
2023-10-04 06:58:55 -07:00
├── Location Details:
2023-10-04 08:11:53 -07:00
│ ├── latitude
│ ├── longitude
2024-04-16 18:01:20 -07:00
│ ├── nearby_schools
├── Agent Info:
2024-08-20 05:19:15 -07:00
│ ├── agent_id
│ ├── agent_name
2024-05-02 09:04:49 -07:00
│ ├── agent_email
│ └── agent_phone
2024-05-31 22:17:29 -07:00
├── Broker Info:
2024-08-20 05:19:15 -07:00
│ ├── broker_id
│ └── broker_name
├── Builder Info:
│ ├── builder_id
│ └── builder_name
├── Office Info:
│ ├── office_id
│ ├── office_name
│ ├── office_phones
│ └── office_email
2023-09-18 17:35:38 -07:00
```
### Exceptions
The following exceptions may be raised when using HomeHarvest:
2024-08-20 05:19:15 -07:00
- `InvalidListingType` - valid options: `for_sale` , `for_rent` , `sold` , `pending` .
2024-05-02 09:04:49 -07:00
- `InvalidDate` - date_from or date_to is not in the format YYYY-MM-DD.
- `AuthenticationError` - Realtor.com token request failed.