HomeHarvest/README.md

179 lines
8.0 KiB
Markdown
Raw Normal View History

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
2023-09-18 19:02:12 -07:00
**HomeHarvest** is a simple, yet comprehensive, real estate scraping library.
2023-09-15 19:47:46 -07:00
2023-09-18 10:01:52 -07:00
[![Try with Replit](https://replit.com/badge?caption=Try%20with%20Replit)](https://replit.com/@ZacharyHampton/HomeHarvestDemo)
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-09-18 17:35:38 -07:00
*Looking to build a data-focused software product?* **[Book a call](https://calendly.com/zachary-products/15min)** *to work with us.*
2023-09-21 09:55:29 -07:00
Check out another project we wrote: ***[JobSpy](https://github.com/cullenwatson/JobSpy)** a Python package for job scraping*
2023-09-18 17:35:38 -07:00
## Features
- Scrapes properties from **Zillow**, **Realtor.com** & **Redfin** simultaneously
- Aggregates the properties in a Pandas DataFrame
2023-09-18 21:53:10 -07:00
[Video Guide for HomeHarvest](https://youtu.be/JnV7eR2Ve2o) - _updated for release v0.2.7_
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
2023-09-19 14:18:01 -07:00
pip install homeharvest
2023-09-17 13:10:21 -07:00
```
2023-09-18 17:35:38 -07:00
_Python version >= [3.10](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-02 10:28:13 -07:00
### Python
```py
from homeharvest import scrape_property
import pandas as pd
properties: pd.DataFrame = scrape_property(
location="85281",
listing_type="for_rent" # for_sale / sold
)
#: Note, to export to CSV or Excel, use properties.to_csv() or properties.to_excel().
print(properties)
```
2023-09-19 13:01:39 -07:00
### CLI
2023-10-03 22:31:23 -07:00
```
usage: homeharvest [-h] [-l {for_sale,for_rent,sold}] [-o {excel,csv}] [-f FILENAME] [-p PROXY] [-d DAYS] [-r RADIUS] location
Home Harvest Property Scraper
positional arguments:
location Location to scrape (e.g., San Francisco, CA)
options:
-h, --help show this help message and exit
-l {for_sale,for_rent,sold}, --listing_type {for_sale,for_rent,sold}
Listing type to scrape
-o {excel,csv}, --output {excel,csv}
Output format
-f FILENAME, --filename FILENAME
Name of the output file (without extension)
-p PROXY, --proxy PROXY
Proxy to use for scraping
-d DAYS, --days DAYS Sold in last _ days filter.
-r RADIUS, --radius RADIUS
Get comparable properties within _ (eg. 0.0) miles. Only applicable for individual addresses.
```
2023-09-19 13:01:39 -07:00
```bash
2023-10-03 22:31:23 -07:00
> homeharvest "San Francisco, CA" -l for_rent -o excel -f HomeHarvest
2023-09-19 13:01:39 -07:00
```
2023-09-18 17:35:38 -07:00
## Output
```py
2023-09-18 19:02:12 -07:00
>>> properties.head()
2023-09-19 11:08:08 -07:00
property_url site_name listing_type apt_min_price apt_max_price ...
0 https://www.redfin.com/AZ/Tempe/1003-W-Washing... redfin for_rent 1666.0 2750.0 ...
1 https://www.redfin.com/AZ/Tempe/VELA-at-Town-L... redfin for_rent 1665.0 3763.0 ...
2 https://www.redfin.com/AZ/Tempe/Camden-Tempe/a... redfin for_rent 1939.0 3109.0 ...
3 https://www.redfin.com/AZ/Tempe/Emerson-Park/a... redfin for_rent 1185.0 1817.0 ...
4 https://www.redfin.com/AZ/Tempe/Rio-Paradiso-A... redfin for_rent 1470.0 2235.0 ...
[5 rows x 41 columns]
2023-09-17 13:10:21 -07:00
```
2023-09-18 08:38:56 -07:00
2023-09-18 17:35:38 -07:00
### Parameters for `scrape_properties()`
```plaintext
Required
├── location (str): address in various formats e.g. just zip, full address, city/state, etc.
└── listing_type (enum): for_rent, for_sale, sold
Optional
2023-09-19 19:35:37 -07:00
├── site_name (list[enum], default=all three sites): zillow, realtor.com, redfin
2023-09-19 13:43:24 -07:00
├── proxy (str): in format 'http://user:pass@host:port' or [https, socks]
2023-09-20 18:25:50 -07:00
└── keep_duplicates (bool, default=False): whether to keep or remove duplicate properties based on address
2023-09-18 17:35:38 -07:00
```
### Property Schema
```plaintext
Property
├── Basic Information:
│ ├── property_url (str)
│ ├── site_name (enum): zillow, redfin, realtor.com
2023-09-19 19:35:37 -07:00
│ ├── listing_type (enum): for_sale, for_rent, sold
2023-09-18 17:35:38 -07:00
│ └── property_type (enum): house, apartment, condo, townhouse, single_family, multi_family, building
├── Address Details:
│ ├── street_address (str)
│ ├── city (str)
│ ├── state (str)
│ ├── zip_code (str)
│ ├── unit (str)
│ └── country (str)
2023-09-19 19:35:37 -07:00
├── House for Sale Features:
2023-09-18 17:35:38 -07:00
│ ├── tax_assessed_value (int)
│ ├── lot_area_value (float)
│ ├── lot_area_unit (str)
│ ├── stories (int)
2023-09-19 19:35:37 -07:00
│ ├── year_built (int)
│ └── price_per_sqft (int)
├── Building for Sale and Apartment Details:
│ ├── bldg_name (str)
│ ├── beds_min (int)
│ ├── beds_max (int)
│ ├── baths_min (float)
│ ├── baths_max (float)
│ ├── sqft_min (int)
│ ├── sqft_max (int)
│ ├── price_min (int)
│ ├── price_max (int)
│ ├── area_min (int)
│ └── unit_count (int)
2023-09-18 17:35:38 -07:00
├── Miscellaneous Details:
│ ├── mls_id (str)
│ ├── agent_name (str)
│ ├── img_src (str)
│ ├── description (str)
│ ├── status_text (str)
2023-09-19 19:35:37 -07:00
│ └── posted_time (str)
2023-09-18 17:35:38 -07:00
2023-09-19 19:35:37 -07:00
└── Location Details:
├── latitude (float)
└── longitude (float)
2023-09-18 17:35:38 -07:00
```
## Supported Countries for Property Scraping
* **Zillow**: contains listings in the **US** & **Canada**
* **Realtor.com**: mainly from the **US** but also has international listings
* **Redfin**: listings mainly in the **US**, **Canada**, & has expanded to some areas in **Mexico**
### Exceptions
The following exceptions may be raised when using HomeHarvest:
- `InvalidSite` - valid options: `zillow`, `redfin`, `realtor.com`
- `InvalidListingType` - valid options: `for_sale`, `for_rent`, `sold`
- `NoResultsFound` - no properties found from your input
2023-09-19 19:35:37 -07:00
- `GeoCoordsNotFound` - if Zillow scraper is not able to derive geo-coordinates from the location you input
2023-09-18 17:35:38 -07:00
## Frequently Asked Questions
---
**Q: Encountering issues with your queries?**
2023-09-18 17:45:14 -07:00
**A:** Try a single site and/or broaden the location. If problems persist, [submit an issue](https://github.com/ZacharyHampton/HomeHarvest/issues).
2023-09-18 17:35:38 -07:00
---
**Q: Received a Forbidden 403 response code?**
**A:** This indicates that you have been blocked by the real estate site for sending too many requests. Currently, **Zillow** is particularly aggressive with blocking. We recommend:
2023-09-18 08:38:56 -07:00
2023-09-18 17:35:38 -07:00
- Waiting a few seconds between requests.
2023-09-18 17:39:22 -07:00
- Trying a VPN to change your IP address.
2023-09-18 08:38:56 -07:00
2023-09-18 17:35:38 -07:00
---
2023-09-18 08:38:56 -07:00