pyzillow
pyzillow copied to clipboard
No error code generated with address mismatch
Hello, my name is Kirill. Firstly, thank you very much for creating this tool, it really helps. I am having an issue with using .get_deep_search_results while giving it an address that Zillow does not have. it gives me the following error:
<pyzillow.pyzillow.ZillowWrapper object at 0x104598f60>
Traceback (most recent call last):
File "bot_v2.py", line 37, in <module>
botv2()
File "bot_v2.py", line 34, in botv2
houseDB[idx].price = zillow.getprice(houseDB[idx].address, houseDB[idx].zipcode)
File "/Users/Tyler/Bot/zillow.py", line 9, in getprice
deep_search_response = zildat.get_deep_search_results(address, zipcode)
File "/usr/local/lib/python3.6/site-packages/pyzillow/pyzillow.py", line 31, in get_deep_search_results
return self.get_data(url, params)
File "/usr/local/lib/python3.6/site-packages/pyzillow/pyzillow.py", line 82, in get_data
raise ZillowError(int(response.findall('message/code')[0].text))
pyzillow.pyzillowerrors.ZillowError: <exception str() failed>
this is the code:
from pyzillow.pyzillow import ZillowWrapper, GetDeepSearchResults
def getprice(address, zipcode):
# address = '4315 Gadwall Pl, Virginia Beach, VA'
# zipcode = '23462'
zid = 'X1-ZWz195wfkezrpn_93aho'
zildat = ZillowWrapper(zid)
print(zildat)
deep_search_response = zildat.get_deep_search_results(address, zipcode)
result = GetDeepSearchResults(deep_search_response)
price = result.last_sold_price
return price
What I am aiming to achieve is the error code so that I can move on to the next address if the precious does not work. Unfortunately I can not proceed because of this error.
Thank you in advance
You can access the error code and text by catching the ZillowError exception.
from pyzillow.pyzillow import ZillowWrapper, GetDeepSearchResults, ZillowError
def getprice(address, zipcode):
zid = 'put_api_key_here'
zildat = ZillowWrapper(zid)
try:
deep_search_response = zildat.get_deep_search_results(address, zipcode)
except ZillowError as e:
message = e.message['text']
code = e.message['code']
print("Error: {code} - {message}".format(code=code, message=message))
return 0
result = GetDeepSearchResults(deep_search_response)
price = result.last_sold_price
return price
print(getprice('999 Nosuch Street', 23462))