diff --git a/testdata/rent_zestimate.xml b/testdata/rent_zestimate.xml new file mode 100644 index 0000000..58a2402 --- /dev/null +++ b/testdata/rent_zestimate.xml @@ -0,0 +1,75 @@ + + + +
2114 Bigelow Ave
+ Seattle, WA +
+ + Request successfully processed + 0 + + + + + 48749425 + + http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/ + http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#charts-and-data + http://www.zillow.com/homes/48749425_zpid/ + http://www.zillow.com/homes/comps/48749425_zpid/ + +
+ 2114 Bigelow Ave N + 98109 + Seattle + WA + 47.637933 + -122.347938 +
+ 53033 + SingleFamily + 2014 + 1060000.0 + 1924 + 4680 + 3470 + 3.0 + 4 + 11/26/2008 + 1025000 + + 1399263 + 02/23/2016 + + -11305 + + 1301315 + 1511204 + + 0 + + + 5495 + 02/24/2016 + + 17 + + 4011 + 6209 + + + + + 727,500 + + http://www.zillow.com/local-info/WA-Seattle/East-Queen-Anne/r_271856/ + http://www.zillow.com/east-queen-anne-seattle-wa/fsbo/ + http://www.zillow.com/east-queen-anne-seattle-wa/ + + + +
+
+
+
+ diff --git a/tests/test_valuation.py b/tests/test_valuation.py index 0b89f45..c114c4d 100644 --- a/tests/test_valuation.py +++ b/tests/test_valuation.py @@ -16,7 +16,23 @@ def test_search_results(self): place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result']) self.assertEqual("2100641621", place.zpid) - self.assertEqual(1723665, place.zestiamte.amount) + self.assertEqual(1723665, place.zestimate.amount) + + def test_rent_zestimate(self): + RAW_XML = "" + with open('./testdata/rent_zestimate.xml', 'r') as f: + RAW_XML = ''.join(f.readlines()) + + data = xmltodict.parse(RAW_XML) + + place = Place() + place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result']) + + self.assertEqual("48749425", place.zpid) + self.assertEqual(5495, place.rentzestimate.amount) + self.assertEqual(4011, place.rentzestimate.valuation_range_low) + self.assertEqual(6209, place.rentzestimate.valuation_range_high) + self.assertEqual(17, place.rentzestimate.amount_change_30days) def test_zestimate(self): RAW_XML = "" @@ -29,7 +45,7 @@ def test_zestimate(self): place.set_data(data.get('Zestimate:zestimate', None)['response']) self.assertEqual("2100641621", place.zpid) - self.assertEqual(1723665, place.zestiamte.amount) + self.assertEqual(1723665, place.zestimate.amount) def test_getcomps_principal(self): RAW_XML = "" diff --git a/zillow/api.py b/zillow/api.py index 05d5c6f..6f98e11 100644 --- a/zillow/api.py +++ b/zillow/api.py @@ -34,7 +34,7 @@ def __init__(self): self.__auth = None self._timeout = None - def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): + def GetSearchResults(self, zws_id, address, citystatezip, rentzestimate=False): """ The GetSearchResults API finds a property for a specified address. The content returned contains the address for the property or properties as well as the Zillow Property ID (ZPID) and current Zestimate. @@ -53,8 +53,8 @@ def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): parameters['citystatezip'] = citystatezip else: raise ZillowError({'message': "Specify address and citystatezip."}) - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -69,7 +69,7 @@ def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): return place - def GetZEstimate(self, zws_id, zpid, retnzestimate=False): + def GetZEstimate(self, zws_id, zpid, rentzestimate=False): """ The GetZestimate API will only surface properties for which a Zestimate exists. If a request is made for a property that has no Zestimate, an error code is returned. @@ -78,14 +78,14 @@ def GetZEstimate(self, zws_id, zpid, retnzestimate=False): For more information, see our Zestimate coverage. :zws_id: The Zillow Web Service Identifier. :param zpid: The address of the property to search. This string should be URL encoded. - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: """ url = '%s/GetZestimate.htm' % (self.base_url) parameters = {'zws-id': zws_id, 'zpid': zpid} - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -100,7 +100,7 @@ def GetZEstimate(self, zws_id, zpid, retnzestimate=False): return place - def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): + def GetDeepSearchResults(self, zws_id, address, citystatezip, rentzestimate=False): """ The GetDeepSearchResults API finds a property for a specified address. The result set returned contains the full address(s), zpid and Zestimate data that is provided by the GetSearchResults API. @@ -108,7 +108,7 @@ def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=Fals :zws_id: The Zillow Web Service Identifier. :param address: The address of the property to search. This string should be URL encoded. :param citystatezip: The city+state combination and/or ZIP code for which to search. - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: Example: @@ -119,8 +119,8 @@ def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=Fals 'citystatezip': citystatezip } - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -197,7 +197,7 @@ def GetComps(self, zws_id, zpid, count=25, rentzestimate=False): and Zestimate for the comparable properties and the principal property for which the comparables are being retrieved. :param zpid: The address of the property to search. This string should be URL encoded. :param count: The number of comparable recent sales to obtain (integer between 1 and 25) - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: """ url = '%s/GetComps.htm' % (self.base_url) diff --git a/zillow/place.py b/zillow/place.py index d1863ac..14207c8 100644 --- a/zillow/place.py +++ b/zillow/place.py @@ -168,7 +168,8 @@ def __init__(self, has_extended_data=False): self.zpid = None self.links = Links() self.full_address = FullAddress() - self.zestiamte = ZEstimateData() + self.zestimate = ZEstimateData() + self.rentzestimate = ZEstimateData() self.local_realestate = LocalRealEstate() self.similarity_score = None self.extended_data = ExtendedData() @@ -185,7 +186,9 @@ def set_data(self, source_data): self.similarity_score = source_data.get('@score', None) self.links.set_data(source_data['links']) self.full_address.set_data(source_data['address']) - self.zestiamte.set_data(source_data['zestimate']) + self.zestimate.set_data(source_data['zestimate']) + if 'rentzestimate' in source_data.keys(): + self.rentzestimate.set_data(source_data['rentzestimate']) self.local_realestate.set_data(source_data['localRealEstate']) if self.has_extended_data: self.extended_data.set_data(source_data) @@ -196,7 +199,8 @@ def get_dict(self): 'similarity_score': self.similarity_score, 'links': self.links.get_dict(), 'full_address': self.full_address.get_dict(), - 'zestimate': self.zestiamte.get_dict(), + 'zestimate': self.zestimate.get_dict(), + 'rentzestimate': self.rentzestimate.get_dict(), 'local_realestate': self.local_realestate.get_dict(), 'extended_data': self.extended_data.get_dict() }