reteps / redfin

A Python wrapper around redfin's unofficial API.
MIT License
106 stars 40 forks source link

HTTPError: 403 Client Error: Forbidden for url: https://redfin.com/stingray/do/location-autocomplete?location=4544+Radnor+St%2C+Detroit+Michigan&v=2 #1

Closed vpmkw closed 3 years ago

vpmkw commented 3 years ago
from redfin import Redfin

client = Redfin()

address = '4544 Radnor St, Detroit Michigan'

response = client.search(address)
url = response['payload']['exactMatch']['url']
initial_info = client.initial_info(url)

property_id = initial_info['payload']['propertyId']
listing_id = initial_info['payload']['listingId']

mls_data = client.below_the_fold(property_id, listing_id)
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-11-d6fe599d587c> in <module>()
      5 address = '4544 Radnor St, Detroit Michigan'
      6 
----> 7 response = client.search(address)
      8 url = response['payload']['exactMatch']['url']
      9 initial_info = client.initial_info(url)

2 frames
/usr/local/lib/python3.7/dist-packages/requests/models.py in raise_for_status(self)
    939 
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 
    943     def close(self):

HTTPError: 403 Client Error: Forbidden for url: https://redfin.com/stingray/do/location-autocomplete?location=4544+Radnor+St%2C+Detroit+Michigan&v=2

image_6487327 (1)

image_6487327

reteps commented 3 years ago

please run this command in terminal and tell me what you get.

curl --request GET 
  --url 'https://www.redfin.com/stingray/do/location-autocomplete?location=4544%20radnor%20st&v=2' 
  --header 'User-Agent: redfin' 

For example, my output is:

{}&&{"version":369,"errorMessage":"Success","resultCode":0,"payload":{"sections":[{"rows":
[{"id":"1_60973374","type":"1","name":"4544 Radnor St","subName":"Detroit, MI, USA","url":"/MI/Detroit/4544-Radnor-St-
48224/home/60973374","active":true,"claimedHome":false,"invalidMRS":false,"businessMarketIds":
[45],"countryCode":"US","searchStatusId":128}],"name":"Addresses"}],"exactMatch":{"id":"1_60973374","type":"1","name":"4544 
Radnor St","subName":"Detroit, MI, USA","url":"/MI/Detroit/4544-Radnor-St-
48224/home/60973374","active":true,"claimedHome":false,"invalidMRS":false,"businessMarketIds":
[45],"countryCode":"US","searchStatusId":128},"extraResults":
{},"responseTime":0,"hasFakeResults":false,"isGeocoded":false,"isRedfinServiced":false}}~
reteps commented 3 years ago

@vpmkw

reteps commented 3 years ago

Closing unless more information is provided.

miguelbp22 commented 1 year ago

Hey @reteps, piggybacking on this thread since I'm getting the same '403 Client Error'.

I ran the command you suggest and got this output:

{}&&{"version":463,"errorMessage":"Success","resultCode":0,"payload":{"sections":[{"rows":[{"id":"1_60973374","type":"1","name":"4544 Radnor St","subName":"Detroit, MI, USA","url":"/MI/Detroit/4544-Radnor-St-48224/home/60973374","urlV2":"/MI/Detroit/4544-Radnor-St-48224/home/60973374","active":true,"claimedHome":false,"invalidMRS":false,"businessMarketIds":[45],"countryCode":"US","hasRental":false}],"name":"Addresses"}],"exactMatch":{"id":"1_60973374","type":"1","name":"4544 Radnor St","subName":"Detroit, MI, USA","url":"/MI/Detroit/4544-Radnor-St-48224/home/60973374","urlV2":"/MI/Detroit/4544-Radnor-St-48224/home/60973374","active":true,"claimedHome":false,"invalidMRS":false,"businessMarketIds":[45],"countryCode":"US","hasRental":false},"extraResults":{},"responseTime":0,"hasFakeResults":false,"isGeocoded":false,"isRedfinServiced":false}}

Any insight would be greatly appreciated.

For context, I have a list of urls I was able to download directly from Redfin that looks at recently sold properties in our area with some filters put in place, with the aim of extracting some additional info I think would be really valuable for a predictive model I want to build (like list price since the downloadable data only provides sold price) to get a sense of what we should be bidding on houses as we gear up to enter the housing market in our area. Many thanks!