Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error code generated with address mismatch #14

Open
krav4 opened this issue Jun 13, 2017 · 1 comment
Open

No error code generated with address mismatch #14

krav4 opened this issue Jun 13, 2017 · 1 comment

Comments

@krav4
Copy link

krav4 commented Jun 13, 2017

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

@jeffbrl
Copy link

jeffbrl commented Aug 1, 2017

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants