Example #1
0
def generate_Comp_fields_txt():

    f_name = open("UpdatedHomeLatLong.txt", "r")

    data_base = open("OnlyCompFields.txt", "+w")

    write_out = "street_address | zipcode | zillow_id | Zestimate | Home_type | num_bath | num_bed | home_size | Lat | Long | img url | home description "
    data_base.write(write_out)
    #f_name=["2893 Springdale Ln, Boulder, CO|80303|13239207|630640|Townhouse|3.5|1|1297|40.009373|-105.255454"]
    x = 0
    for line in f_name:
        line = line.rstrip("\n")
        address = line
        if x == 100:
            break
        try:
            street_address = re.search("(.*?)(?<=CO)", address)
            street_address = street_address.group(0)
            zipcode = re.search("(?<=CO\|)(.*?)(?=\|)", address)
            zipcode = zipcode.group(0)

            #!Get information from first zillow call
            zillow_data = ZillowWrapper(zws_id)
            deep_search_response = zillow_data.get_deep_search_results(
                street_address, zipcode)
            result = GetDeepSearchResults(deep_search_response)

            #!!The following will be stored as values in database
            Home_type = result.home_type
            Zestimate = result.zestimate_amount
            zillow_id = result.zillow_id
            lat = str(result.latitude)
            long_res = str(result.longitude)

            num_bath = str(result.bathrooms)
            num_bed = str(result.bedrooms)
            home_size = str(result.home_size)

            #######CALL TO UPDATED HOME DETAILS
            zillow_data = ZillowWrapper(zws_id)
            updated_property_details_response = zillow_data.get_updated_property_details(
                zillow_id)
            result = GetUpdatedPropertyDetails(
                updated_property_details_response)
            photo_gall = result.photo_gallery
            home_d = result.home_description

            write_out = street_address + '|' + zipcode + "|" + zillow_id + "|" + Zestimate + "|" + num_bath + "|" + num_bed + "|" + lat + "|" + long_res + "\n"
            print(str(write_out))
            data_base.write(write_out)
            x += 1

        except:
            print("Nothing Added")

    #f_name.close()
    data_base.close()
Example #2
0
def get_home_description(address, zipcode):
    ZILLOW_API_KEY = "X1-ZWz1fssph6dr7v_2hwdv"

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

    updated_property_details_response = zillow_data.get_updated_property_details(result.zillow_id)
    result_details = GetUpdatedPropertyDetails(updated_property_details_response)

    return result_details.get_attr("home_description")
Example #3
0
    def test_get_updated_property_details_results(self):
        """
        """

        zillow_id = '48749425'
        responses.add(
            responses.GET,
            'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm',
            body=
            '<?xml version="1.0" encoding="utf-8"?><UpdatedPropertyDetails:updatedPropertyDetails xmlns:UpdatedPropertyDetails="http://www.zillow.com/static/xsd/UpdatedPropertyDetails.xsd" xsi:schemaLocation="http://www.zillow.com/static/xsd/UpdatedPropertyDetails.xsd http://www.zillowstatic.com/vstatic/34794f0/static/xsd/UpdatedPropertyDetails.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><request><zpid>48749425</zpid></request><message><text>Request successfully processed</text><code>0</code></message><response><zpid>48749425</zpid><pageViewCount><currentMonth>16125</currentMonth><total>16125</total></pageViewCount><address><street>2114 Bigelow Ave N</street><zipcode>98109</zipcode><city>Seattle</city><state>WA</state><latitude>47.637933</latitude><longitude>-122.347938</longitude></address><links><homeDetails>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/</homeDetails><photoGallery>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#image=lightbox%3Dtrue</photoGallery><homeInfo>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/</homeInfo></links><images><count>1</count><image><url>http://photos3.zillowstatic.com/p_d/ISxb3qa8s1cwx01000000000.jpg</url></image></images><editedFacts><useCode>SingleFamily</useCode><bedrooms>4</bedrooms><bathrooms>3.0</bathrooms><finishedSqFt>3470</finishedSqFt><lotSizeSqFt>4680</lotSizeSqFt><yearBuilt>1924</yearBuilt><yearUpdated>2003</yearUpdated><numFloors>2</numFloors><basement>Finished</basement><roof>Composition</roof><view>Water, City, Mountain</view><parkingType>Off-street</parkingType><heatingSources>Gas</heatingSources><heatingSystem>Forced air</heatingSystem><rooms>Laundry room, Walk-in closet, Master bath, Office, Dining room, Family room, Breakfast nook</rooms></editedFacts><neighborhood>Queen Anne</neighborhood><schoolDistrict>Seattle</schoolDistrict><elementarySchool>John Hay</elementarySchool><middleSchool>McClure</middleSchool></response></UpdatedPropertyDetails:updatedPropertyDetails><!-- H:001  T:127ms  S:990  R:Sat Sep 12 23:47:31 PDT 2015  B:4.0.19615-release_20150908-endor.2fa5797~candidate.358c83d -->',
            content_type='application/xml',
            status=200)

        zillow_data = ZillowWrapper(api_key=None)
        updated_property_details_response = \
            zillow_data.get_updated_property_details(zillow_id)
        result = GetUpdatedPropertyDetails(updated_property_details_response)

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

        zillow_id = '48749425'
        responses.add(
            responses.GET,
            'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm',
            body='<?xml version="1.0" encoding="utf-8"?><UpdatedPropertyDetails:updatedPropertyDetails xmlns:UpdatedPropertyDetails="http://www.zillow.com/static/xsd/UpdatedPropertyDetails.xsd" xsi:schemaLocation="http://www.zillow.com/static/xsd/UpdatedPropertyDetails.xsd http://www.zillowstatic.com/vstatic/34794f0/static/xsd/UpdatedPropertyDetails.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><request><zpid>48749425</zpid></request><message><text>Request successfully processed</text><code>0</code></message><response><zpid>48749425</zpid><pageViewCount><currentMonth>16125</currentMonth><total>16125</total></pageViewCount><address><street>2114 Bigelow Ave N</street><zipcode>98109</zipcode><city>Seattle</city><state>WA</state><latitude>47.637933</latitude><longitude>-122.347938</longitude></address><links><homeDetails>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/</homeDetails><photoGallery>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#image=lightbox%3Dtrue</photoGallery><homeInfo>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/</homeInfo></links><images><count>1</count><image><url>http://photos3.zillowstatic.com/p_d/ISxb3qa8s1cwx01000000000.jpg</url></image></images><editedFacts><useCode>SingleFamily</useCode><bedrooms>4</bedrooms><bathrooms>3.0</bathrooms><finishedSqFt>3470</finishedSqFt><lotSizeSqFt>4680</lotSizeSqFt><yearBuilt>1924</yearBuilt><yearUpdated>2003</yearUpdated><numFloors>2</numFloors><basement>Finished</basement><roof>Composition</roof><view>Water, City, Mountain</view><parkingType>Off-street</parkingType><heatingSources>Gas</heatingSources><heatingSystem>Forced air</heatingSystem><rooms>Laundry room, Walk-in closet, Master bath, Office, Dining room, Family room, Breakfast nook</rooms></editedFacts><neighborhood>Queen Anne</neighborhood><schoolDistrict>Seattle</schoolDistrict><elementarySchool>John Hay</elementarySchool><middleSchool>McClure</middleSchool></response></UpdatedPropertyDetails:updatedPropertyDetails><!-- H:001  T:127ms  S:990  R:Sat Sep 12 23:47:31 PDT 2015  B:4.0.19615-release_20150908-endor.2fa5797~candidate.358c83d -->',
            content_type='application/xml',
            status=200
        )

        zillow_data = ZillowWrapper(api_key=None)
        updated_property_details_response = \
            zillow_data.get_updated_property_details(zillow_id)
        result = GetUpdatedPropertyDetails(updated_property_details_response)

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

        zillow_id = "48749425"
        set_updated_property_details_response(
            self.api_response_obj.get("updated_property_details_200_ok"))

        zillow_data = ZillowWrapper(api_key=None)
        updated_property_details_response = zillow_data.get_updated_property_details(
            zillow_id)
        result = GetUpdatedPropertyDetails(updated_property_details_response)

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

        zillow_id = '48749425'

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

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

        zillow_id = '48749425'

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

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

    """
    Returns the zillow estimated price given a property ID.

    """
    zkey = current_app.config['ZKEY']
    zillow_data = ZillowWrapper(zkey)

    # check if already exists in DB and if so, that data is less than a week old, otherwise call zillow API
    db_results = PropertyData.objects(zillow_id=zillow_id)
    if db_results.count() > 0 and db_results[0].created_at > datetime.now()-timedelta(days=7):
        zestimate_amount = db_results[0].zestimate_amount
    else:
        try:
            detail_result = PropDetailsWithAddressAndZip(zillow_data.get_updated_property_details(zillow_id))
            deep_search_result = GetDeepSearchResults(zillow_data.get_deep_search_results(
                detail_result.street, detail_result.zip))
            zestimate_amount = deep_search_result.zestimate_amount
        except ZillowError as err:
            return jsonify({'error': err.message, 'estimate': 0})
    return jsonify({'estimate': zestimate_amount, 'error': ''})
import os
from pyzillow.pyzillow import ZillowWrapper, GetDeepSearchResults, GetUpdatedPropertyDetails

ZILLOW_API_KEY = os.environ['ZILLOW_API_KEY']

address = '13680 SW Berea Dr Tigard OR'
zipcode = '97223'

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

zillow_id = result.zillow_id # zillow id, needed for the GetUpdatedPropertyDetails

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

print result.year_built # number of rooms of the home
def main():
    ## Zillow API call setup ##
    API_KEY = 'X1-ZWz1fmcredpjpn_76gmj'
    zillow_data = ZillowWrapper(API_KEY)

    ## variable setup for iteration through address list (from file) ##
    i = 0
    while i < len(address_list):
        ## check used to determine if ds_result raised an exception - no data
        check = True
        ## upd used to determine if upd_result raised an exception - no data
        upd = True

        address = address_list[i]
        if (check_duplicates(address)):
            i += 1
            exit
        else:
            ## First API call using address/zip ##
            try:
                ds_response = zillow_data.get_deep_search_results(
                    address, '27401')
                ds_result = GetDeepSearchResults(ds_response)
            except (ZillowError, UnicodeEncodeError):
                print('No basic property details for:' + address)
                check = False
            finally:
                exit

            ## If first API call successful, additional details sought from 2nd API call
            if check:
                try:
                    upd_response = zillow_data.get_updated_property_details(
                        ds_result.zillow_id)
                    upd_result = GetUpdatedPropertyDetails(upd_response)
                except (ZillowError, UnicodeEncodeError):
                    print('No updated property details for:' + address)
                    upd = False
                finally:
                    exit

            ## Compares sold date vs. current date to determine "sold" binary status
            ## Older date is "less than" for Python comparison ##
            ## We treat anything sold more than 1 year ago as "unsold" ##

            if check:
                if upd:
                    t = 1
                    if str(ds_result.last_sold_date) != 'None':
                        sale_date = dt.strptime(ds_result.last_sold_date,
                                                "%m/%d/%Y")
                        compare_date = dt.strptime('01/01/2016', "%m/%d/%Y")
                        if sale_date < compare_date:
                            s = 0
                        else:
                            s = 1
                    else:
                        s = 0
                    insert_home(
                        address, 27401, 'Greensboro', 'NC',
                        ds_result.home_type, ds_result.bedrooms,
                        ds_result.bathrooms, ds_result.home_size,
                        ds_result.property_size, ds_result.year_built,
                        upd_result.year_updated, upd_result.num_floors,
                        upd_result.parking_type, upd_result.heating_sources,
                        upd_result.heating_system, upd_result.floor_material,
                        upd_result.num_rooms, str(upd_result.neighborhood),
                        str(upd_result.school_district), s,
                        ds_result.last_sold_date, ds_result.last_sold_price,
                        upd_result.appliances, upd_result.roof,
                        upd_result.rooms, t)
                else:
                    s = 0
                    t = 0
                    default = None
                    insert_home(address, 27401, 'Greensboro', 'NC',
                                ds_result.home_type, ds_result.bedrooms,
                                ds_result.bathrooms, ds_result.home_size,
                                ds_result.property_size, ds_result.year_built,
                                default, default, default, default, default,
                                default, default, default, default, s, default,
                                default, default, default, default, t)
            i += 1
# -*- coding: utf-8 -*-
"""
Created on Tue May 24 22:06:13 2016

@author: Connor
"""

import pandas as pd
import numpy as np
from API_key import *
from pyzillow.pyzillow import ZillowWrapper, GetUpdatedPropertyDetails

# Well, I think I can just iterate on DC-area zillow IDs maybe? The API requires
# specific calls to individual homes, but if I can iterate through them, maybe I
# can record the info I want without actually knowing the homes beforehand.


# Ha, yes. It seems the Zillow IDs are generated iteratively in some fashion,
# so I can at least tease out some basic details on mlutiple home by iterating
# over a relatively small range in a a hack-y API-based scrapign loop.

zillow_data = ZillowWrapper(ZWSID)
updated_property_details_response = zillow_data.get_updated_property_details(4671144)
result = GetUpdatedPropertyDetails(updated_property_details_response)

#print dir(result)

print result.year_built
Example #12
0
# -*- coding: utf-8 -*-
"""
Created on Tue May 24 22:06:13 2016

@author: Connor
"""

import pandas as pd
import numpy as np
from API_key import *
from pyzillow.pyzillow import ZillowWrapper, GetUpdatedPropertyDetails

# Well, I think I can just iterate on DC-area zillow IDs maybe? The API requires
# specific calls to individual homes, but if I can iterate through them, maybe I
# can record the info I want without actually knowing the homes beforehand.

# Ha, yes. It seems the Zillow IDs are generated iteratively in some fashion,
# so I can at least tease out some basic details on mlutiple home by iterating
# over a relatively small range in a a hack-y API-based scrapign loop.

zillow_data = ZillowWrapper(ZWSID)
updated_property_details_response = zillow_data.get_updated_property_details(
    4671144)
result = GetUpdatedPropertyDetails(updated_property_details_response)

#print dir(result)

print result.year_built