Exemple #1
0
    def test_deep_search_results(self):
        """
        Unit test for the wrapper calling the GetDeepSearchResults API 
        """

        address = '2114 Bigelow Ave Seattle, WA'
        zipcode = '98109'

        zillow_data = ZillowWrapper(ZILLOW_API_KEY)
        deep_search_response = zillow_data.get_deep_search_results(address, zipcode)
        result = GetDeepSearchResults(deep_search_response) 

        self.assertEqual(result.zillow_id, '48749425')
        self.assertEqual(result.home_type, 'SingleFamily')
        self.assertEqual(result.home_detail_link, 
          'http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/')
        self.assertEqual(result.graph_data_link, 
          'http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#charts-and-data')
        self.assertEqual(result.map_this_home_link, 
          'http://www.zillow.com/homes/48749425_zpid/')
        self.assertEqual(result.tax_year, '2012')
        self.assertEqual(result.tax_value, '902000.0')
        self.assertEqual(result.year_built, '1924')
        self.assertEqual(result.property_size, '4680')
        self.assertEqual(result.home_size, '3470')
        self.assertEqual(result.bathrooms, '3.0')
        self.assertEqual(result.bedrooms, '4')
        self.assertEqual(result.last_sold_date, '11/26/2008')
        self.assertEqual(result.last_sold_price_currency, 'USD')
        self.assertEqual(result.last_sold_price, '1025000')
        self.assertAlmostEqual(float(result.latitude), 47.637933, 2)
        self.assertAlmostEqual(float(result.longitude), -122.347938, 2)
Exemple #2
0
def test():
    path = Path(__file__).parent.parent / 'config/zillow_key.conf'
    with open(path, 'r') as f:
        key = f.readline().rstrip().replace('\n', '')

    print(key)
    zillow_data = ZillowWrapper(key)

    response = zillow_data.get_deep_search_results(address='574 Revere Way',
                                                   zipcode='08205')
    # response = zillow_data.get_updated_property_details('37807220')
    result = GetDeepSearchResults(response)
    return result
Exemple #3
0
    def test_zillow_api_results(self):
        """
        """

        address = '2114 Bigelow Ave Seattle, WA'
        zipcode = '98109'
        zpid    = '48749425'

        # create expected result from mock data
        deep_search_mock = ElementTree.XML(MOCK_DATA_GET_DEEP_SEARCH_RESULTS)

        # create response from zillow
        zillow_data = ZillowWrapper(ZILLOW_API_KEY)
        deep_search_response = zillow_data.get_deep_search_results(address, zipcode)

        # compare expected with real result
        self.assertEqual(ElementTree.tostringlist(deep_search_response, encoding="us-ascii", method="xml"), 
                          ElementTree.tostringlist(deep_search_mock, encoding="us-ascii", method="xml"))
Exemple #4
0
    def test_get_updated_property_details_results(self):
        """
        """

        zillow_id = '48749425'

        zillow_data = ZillowWrapper(ZILLOW_API_KEY)
        updated_property_details_response = zillow_data.get_updated_property_details(zillow_id)
        result = GetUpdatedPropertyDetails(updated_property_details_response) 

        self.assertEqual(result.zillow_id, '48749425')
        self.assertEqual(result.home_type, 'SingleFamily')
        self.assertEqual(result.home_detail_link, 
          'http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/')
        self.assertEqual(result.photo_gallery, 
          'http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#image=lightbox%3Dtrue')
        self.assertEqual(result.home_info, 
          'http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/')
        self.assertEqual(result.year_built, '1924')
        self.assertEqual(result.property_size, '4680')
        self.assertEqual(result.home_size, '3470')
        self.assertEqual(result.bathrooms, '3.0')
        self.assertEqual(result.bedrooms, '4')
        self.assertEqual(result.year_updated, '2003')
        self.assertEqual(result.basement, 'Finished')
        self.assertEqual(result.roof, 'Composition')
        self.assertEqual(result.view, 'Water, City, Mountain')
        self.assertEqual(result.heating_sources, 'Gas')
        self.assertEqual(result.heating_system, 'Forced air')
        self.assertEqual(result.rooms, 
          'Laundry room, Walk-in closet, Master bath, Office, Dining room, Family room, Breakfast nook')
        self.assertEqual(result.neighborhood, 'Queen Anne')
        self.assertEqual(result.school_district, 'Seattle')
        self.assertAlmostEqual(float(result.latitude), 47.637933, 2)
        self.assertAlmostEqual(float(result.longitude), -122.347938, 2)
        self.assertEqual(result.floor_material, None)
        self.assertEqual(result.num_floors, '2')
        self.assertEqual(result.parking_type, 'Off-street')
Exemple #5
0
##encoding=utf8

from pyzillow import ZillowWrapper, GetDeepSearchResults, GetUpdatedPropertyDetails
from HSH.Data.pk import load_pk, dump_pk

zlid = "X1-ZWz1dyb91hllhn_6msnx"
zillow_data = ZillowWrapper(zlid)

address, zipcode = "5134 HARTWICK RD", "77093"
deep_search_response = zillow_data.get_deep_search_results(address, zipcode)
result = GetDeepSearchResults(deep_search_response)
# print(result.zillow_id) # 37253404
# dump_pk(result.zillow_id, "result_zillow_id.p")

# zillow_id = load_pk("result_zillow_id.p")
# print(zillow_id, type(zillow_id))
updated_property_details_response = zillow_data.get_updated_property_details(result.zillow_id)
result = GetUpdatedPropertyDetails(updated_property_details_response) 
dump_pk(result, "zillow.p")
 with open('WakePropA_Res-Full_v2_RR.csv', 'rb') as readFile:
     with open('WakePropA_Res-Full_v2_RR_Zillow.csv', 'ab') as writeFile:
         reader = csv.reader(readFile)
         writer = csv.writer(writeFile)
         
         ## Write headers into new file (first set of rows only)
         column_names = reader.next()
         column_names.extend(['Zestimate','Rent Zestimate', 'Last Updated', 'RZ 30 Day Change', 'RZ Range Low', 'RZ Range High', 'Home Value Index', 'Use Code', 'Year Built', 'Finished Sq.Ft.', 'Lot Sq.Ft.'])
         #writer.writerow(column_names)
         
         ## For each row within call limit, call Zillow API
         for row in reader:
             if 13026 <= int(row[0]) < 14000:
                 address = row[16]
                 zipcode = row[18]
                 zillow_data = ZillowWrapper(KEY)
                 deep_search_response = zillow_data.get_deep_search_results(address, zipcode)
                 try:
                     result = GetDeepSearchResults(deep_search_response)
                     ## Add API fields into file
                     row.append(result.zestimate_amount)
                     row.append(result.rent_zestimate_amount)
                     row.append(result.rent_zestimate_lastUpdated)
                     row.append(result.rent_zestimate_valueChange)
                     row.append(result.rent_zestimate_valuationRange_low)
                     row.append(result.rent_zestimate_valuationRange_high)
                     row.append(result.home_value_index)
                     row.append(result.home_type)
                     row.append(result.year_built)
                     row.append(result.home_size)
                     row.append(result.property_size)
Exemple #7
0
##encoding=utf8

from pyzillow import ZillowWrapper, GetDeepSearchResults, GetUpdatedPropertyDetails
from HSH.Data.pk import load_pk, dump_pk

zlid = "X1-ZWz1dyb91hllhn_6msnx"
zillow_data = ZillowWrapper(zlid)

address, zipcode = "5134 HARTWICK RD", "77093"
deep_search_response = zillow_data.get_deep_search_results(address, zipcode)
result = GetDeepSearchResults(deep_search_response)
# print(result.zillow_id) # 37253404
# dump_pk(result.zillow_id, "result_zillow_id.p")

# zillow_id = load_pk("result_zillow_id.p")
# print(zillow_id, type(zillow_id))
updated_property_details_response = zillow_data.get_updated_property_details(
    result.zillow_id)
result = GetUpdatedPropertyDetails(updated_property_details_response)
dump_pk(result, "zillow.p")