Skip to content

Commit

Permalink
fix: redfin
Browse files Browse the repository at this point in the history
  • Loading branch information
cullenwatson committed Apr 4, 2024
1 parent 01c53f9 commit d05bc5d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from homeharvest import scrape_property
import pandas as pd

properties: pd.DataFrame = scrape_property(
site_name=["redfin"],
location="85281",
listing_type="for_rent" # for_sale / sold
)

print(properties)
properties.to_csv('properties.csv', index=False)
1 change: 1 addition & 0 deletions homeharvest/core/scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, scraper_input: ScraperInput):
self.listing_type = scraper_input.listing_type

self.session = requests.Session()
self.session.headers.update({"user-agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'})
if scraper_input.proxy:
proxy_url = scraper_input.proxy
proxies = {"http": proxy_url, "https": proxy_url}
Expand Down
2 changes: 1 addition & 1 deletion homeharvest/core/scrapers/redfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, scraper_input):
def _handle_location(self):
url = "https://www.redfin.com/stingray/do/location-autocomplete?v=2&al=1&location={}".format(self.location)

response = self.session.get(url)
response = self.session.get(url, headers={"user-agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'})
response_json = json.loads(response.text.replace("{}&&", ""))

def get_region_type(match_type: str):
Expand Down

0 comments on commit d05bc5d

Please sign in to comment.