Example #1
0
def make_predict():
    # read in data
    lines = request.get_json(force=True)
    address = lines['address']
    city = lines['city']
    state = lines['state']
    zipcode = lines['zipcode']
    bed = lines['bed']
    bath = lines['bath']
    SqFt = lines['SqFt']
    year = lines['year']

    # generate prediction using pickled model
    input = np.array([[bath, bed, SqFt, year, zipcode]])
    prediction = model.predict(input)
    output = list(prediction[0])[0]

    # compare against zillow model
    zillow_data = ZillowWrapper(API_KEY_HERE)
    deep_search_response = zillow_data.get_deep_search_results(
        address, zipcode)
    result = GetDeepSearchResults(deep_search_response)
    output2 = result.zestimate_amount
    op = list([int(output), int(output2)])
    return jsonify(results=op)
Example #2
0
def make_predict():
    lines = request.get_json(force=True) # was 'data'
    # predict_request = [data['address'], data['city'], data['state'],
    # data['zipcode'], data['bed'], data['bath'], data['SqFt'],
    # data['SqFt']]
    # predict_request = [np.array(predict_request)]
    # y_hat = reg.predict(predict_request)
    address = lines['address']
    city = lines['city']
    state = lines['state']
    zipcode = lines['zipcode']
    bed = lines['bed']
    bath = lines['bath']
    SqFt = lines['SqFt']
    year = lines['year'] 
    
    test_case = np.array([[bath, bed, SqFt, year, zipcode]])
    reg.predict(test_case)
    prediction = reg.predict(test_case)
    output = list(prediction[0])[0]
    #return jsonify(results=address)
    
    zillow_data = ZillowWrapper('X1-ZWz1gyajrkda8b_76gmj')
    deep_search_response = zillow_data.get_deep_search_results(address,zipcode)
    result = GetDeepSearchResults(deep_search_response)
    output2 = result.zestimate_amount
    op = list([int(output),int(output2)])
    return jsonify(results=op)
Example #3
0
def get_property_info(address, zipcode):
    if address and zipcode:
        zillow_data = ZillowWrapper(ZILLOW_API_KEY)
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_response)
        return result
    def search(self, query):
        address, zipcode = query.rsplit(" ", 1)

        data = ZillowWrapper("X1-ZWz19cu0z5xn9n_17jma")
        response = data.get_deep_search_results(address, zipcode)

        return GetDeepSearchResults(response)
Example #5
0
 def parse(self, address):
     address, zip_code, _  = re.search(r'(.*)(\d{5}(-\d{4})?)$', address).groups()
     result = GetDeepSearchResults(self._zillow_data.get_deep_search_results(address, zip_code))
     return {
         self.headers[0]: result.zestimate_amount,
         self.headers[1]: result.last_sold_date
     }
Example #6
0
def bergenentry(sh, zillow_data, number):
    worksheet = sh.get_worksheet(number)
    csvfile = open("bergen_items.csv", "rb")
    reader = csv.reader(csvfile)
    start = 2
    for line in reader:
        #print line
        if line[0] is not "":
            address = line[6]
            address.replace("\n", " ")
            zipcode = address[-5:]

            try:
                deep_search_response = zillow_data.get_deep_search_results(
                    address, zipcode)
                result = GetDeepSearchResults(deep_search_response)
                zestimate = result.zestimate_amount
            except pyzillow.pyzillowerrors.ZillowError as err:
                #print ("No Zillow Found!")
                zestimate = 0

            worksheet.update_cell(start, 1, line[8] + "->" + line[4])  #date
            worksheet.update_cell(start, 2, line[1])  #shf no
            worksheet.update_cell(start, 3, line[3])  #case
            worksheet.update_cell(start, 4,
                                  "PLF: " + line[0] + "\n" + "DEF: " + line[7])
            worksheet.update_cell(start, 5, line[5])  #att
            worksheet.update_cell(start, 6, address)  #add
            worksheet.update_cell(start, 9, line[2])  #upset
            worksheet.update_cell(start, 14, zestimate)  #zillow
            start = start + 1
def search_address(zillow_data):
    """Get results from address input and zipcode input."""
    deep_search_response = zillow_data.get_deep_search_results(
        address, zipcode)
    result = GetDeepSearchResults(deep_search_response)
    if args.verbose:
        print(result)
    return result
Example #8
0
def get_summary(address, zipcode):
    with open('/Users/pjadzinsky/.zillow') as f:
        key = f.read().replace('\n', '')
    zillow_data = ZillowWrapper(key)

    response = zillow_data.get_deep_search_results(address, zipcode)
    result = GetDeepSearchResults(response)
    return result
Example #9
0
def deep_search():
    cnxt = db.connect(user="******",
                      password="******",
                      host="localhost",
                      database="sys",
                      charset="utf8mb4")
    cursor = cnxt.cursor()
    cursor.execute("SELECT Address FROM PySpider")
    data = cursor.fetchall()
    A = [" ".join(j) for j in [i[0].split()[:-1] for i in data]]
    Z = [" ".join(j) for j in [i[0].split()[-1:] for i in data]]
    API = ZillowWrapper('X1-ZWz1gtmiat11xn_7ew1d')
    progbar = tqdm(total=len(A))
    for i in range(len(A)):
        progbar.update(1)
        try:
            response = API.get_deep_search_results(A[i], Z[i])
            result = GetDeepSearchResults(response)
            zestimate_amount = result.zestimate_amount
            address = A[i]
            zipcode = Z[i]
            home_type = result.home_type
            home_size = result.home_size
            property_size = result.property_size
            bedrooms = result.bedrooms
            bathrooms = result.bathrooms
            last_sold_price = result.last_sold_price
            last_sold_date = result.last_sold_date
            zestimate_last_updated = result.zestimate_last_updated
            zestimate_value_change = result.zestimate_value_change
            zestimate_percentile = result.zestimate_percentile
            zestimate_valuation_range_high = result.zestimate_valuation_range_high
            zestimate_valuationRange_low = result.zestimate_valuationRange_low
            year_built = result.year_built
            home_detail_link = result.home_detail_link

            query = "INSERT INTO PyZillow (zestimate_amount, address, zipcode, home_type, home_size,\
            property_size, bedrooms, bathrooms, last_sold_price, last_sold_date,\
            zestimate_last_updated, zestimate_value_change, zestimate_percentile,\
            zestimate_valuation_range_high, zestimate_valuationRange_low, year_built,\
            home_detail_link) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

            cursor.execute(
                query,
                (zestimate_amount, address, zipcode, home_type, home_size,
                 property_size, bedrooms, bathrooms, last_sold_price,
                 last_sold_date, zestimate_last_updated,
                 zestimate_value_change, zestimate_percentile,
                 zestimate_valuation_range_high, zestimate_valuationRange_low,
                 year_built, home_detail_link))
            cnxt.commit()

        except:
            continue
    progbar.close()

    return
Example #10
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 #11
0
    def getResults(self):
        """
        Method that returns a dict() of data about the house at the coordinates of loc_x, loc_y.

        """

        deep_search_response = self.zillow_data.get_deep_search_results(
            self.address, self.zipcode)
        result = GetDeepSearchResults(deep_search_response)
        return result
def zillow_query(key, address, citystatezip):

    zillow = []
    zillow_data = ZillowWrapper(key)
    deep_search_response = zillow_data.get_deep_search_results(
        address, citystatezip)
    result = GetDeepSearchResults(deep_search_response)

    #Print the results of the query

    return result
Example #13
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")
def zillow_query(address, zipcode):
    '''
    Given an address and zipcode as strings returns id, zestimate (or last sold price if zestimate unavilable), and latest tax appraisal value
    '''
    zillow_data = ZillowWrapper(keys.zillow['api_key'])
    deep_search_response = zillow_data.get_deep_search_results(
        address, zipcode)
    result = GetDeepSearchResults(deep_search_response)
    if result.zestimate_amount == None:
        return result.last_sold_price
    else:
        return result.zillow_id, result.zestimate_amount, result.tax_value
Example #15
0
def queryAndExtractFeatures(inputs, code):
    results = {}
    for address, zipcode in inputs:
        zillow_data = ZillowWrapper(code)
        try:
            deep_search_response = zillow_data.get_deep_search_results(
                address, zipcode)
            result = GetDeepSearchResults(deep_search_response)
            results[(address, zipcode)] = extractFeatures(result) + [zipcode]
        except:
            continue
    return results
Example #16
0
    def test_deep_search_results(self):
        """
        """

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

        responses.add(
            responses.GET,
            'http://www.zillow.com/webservice/GetDeepSearchResults.htm',
            body=
            '<?xml version="1.0" encoding="utf-8"?><SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/34794f0/static/xsd/SearchResults.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd"><request><address>2114 Bigelow Ave Seattle, WA</address><citystatezip>98109</citystatezip></request><message><text>Request successfully processed</text><code>0</code></message><response><results><result><zpid>48749425</zpid><links><homedetails>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/</homedetails><graphsanddata>http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#charts-and-data</graphsanddata><mapthishome>http://www.zillow.com/homes/48749425_zpid/</mapthishome><comparables>http://www.zillow.com/homes/comps/48749425_zpid/</comparables></links><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><FIPScounty>53033</FIPScounty><useCode>SingleFamily</useCode><taxAssessmentYear>2014</taxAssessmentYear><taxAssessment>1060000.0</taxAssessment><yearBuilt>1924</yearBuilt><lotSizeSqFt>4680</lotSizeSqFt><finishedSqFt>3470</finishedSqFt><bathrooms>3.0</bathrooms><bedrooms>4</bedrooms><lastSoldDate>11/26/2008</lastSoldDate><lastSoldPrice currency="USD">1025000</lastSoldPrice><zestimate><amount currency="USD">1419804</amount><last-updated>09/10/2015</last-updated><oneWeekChange deprecated="true"></oneWeekChange><valueChange duration="30" currency="USD">20690</valueChange><valuationRange><low currency="USD">1292022</low><high currency="USD">1547586</high></valuationRange><percentile>0</percentile></zestimate><localRealEstate><region name="East Queen Anne" id="271856" type="neighborhood"><zindexValue>629,900</zindexValue><links><overview>http://www.zillow.com/local-info/WA-Seattle/East-Queen-Anne/r_271856/</overview><forSaleByOwner>http://www.zillow.com/east-queen-anne-seattle-wa/fsbo/</forSaleByOwner><forSale>http://www.zillow.com/east-queen-anne-seattle-wa/</forSale></links></region></localRealEstate></result></results></response></SearchResults:searchresults><!-- H:003  T:27ms  S:1181  R:Sat Sep 12 23:30:47 PDT 2015  B:4.0.19615-release_20150908-endor.2fa5797~candidate.358c83d -->',
            content_type='application/xml',
            status=200)

        zillow_data = ZillowWrapper(api_key=None)
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_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.graph_data_link == \
            'http://www.zillow.com/homedetails/' + \
            '2114-Bigelow-Ave-N-Seattle-WA-98109/' + \
            '48749425_zpid/#charts-and-data'
        assert result.map_this_home_link == \
            'http://www.zillow.com/homes/48749425_zpid/'
        assert result.tax_year == '2014'
        assert result.tax_value == '1060000.0'
        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.last_sold_date == '11/26/2008'
        assert result.last_sold_price_currency == 'USD'
        assert result.last_sold_price == '1025000'
        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.zestimate_amount == '1419804'
        # assert result.zestimate_currency == 'USD'
        assert result.zestimate_last_updated == '09/10/2015'
        assert result.zestimate_value_change == '20690'
        assert result.zestimate_valuation_range_high == '1547586'
        assert result.zestimate_valuation_range_low == '1292022'
        assert result.zestimate_percentile == '0'
Example #17
0
    def updatePropertiesWithZillowData(self, properties):
        for prop in properties:
            updated_prop = copy.deepcopy(prop)
            is_updated = False
            result = None
            logging.info("Updating: %s, %s, %s", prop["address"], prop["city"],
                         prop["zip"])

            try:
                result = self.getDeepSearchResults(address=prop["address"],
                                                   citystatezip=prop["city"] +
                                                   ", " + prop["zip"])
            except ZillowError as e:
                logging.error("No Zillow data found for: %s, %s, %s",
                              prop["address"], prop["city"], prop["zip"])
                logging.error("ZillowError: %s", e.message)
                # Set invalid zillow-id if no exact match was found for input address
                if e.status in [500, 501, 502, 503, 504, 506, 507, 508]:
                    result = GetDeepSearchResults(
                        data=ElementTree.fromstring(ZILLOW_NOT_FOUND_RESPONSE))

            if result:
                for field in ZILLOW_FIELDS:
                    # Map property fields to Zillow fields.
                    if field == "zillow_url":
                        zillow_field = "home_detail_link"
                    else:
                        zillow_field = field

                    if not hasattr(result, zillow_field):
                        continue

                    old_value = prop.get(field, "")
                    new_value = getattr(result, zillow_field)

                    # Only update fields that have changed.
                    if (new_value != None
                            and str(new_value) != str(old_value)):
                        logging.info("%s: %s -> %s", field, old_value,
                                     new_value)
                        updated_prop[field] = new_value
                        is_updated = True

            if is_updated:
                logging.info("Updating: %s", prop["address"])
                updated_prop["last_update"] = strftime("%Y-%m-%d %H:%M:%S",
                                                       localtime())
                updated_prop["zillow_last_update"] = updated_prop[
                    "last_update"]

            yield updated_prop, is_updated
Example #18
0
def parse_zestimate_attributes(address, zillow_attrs):
    if not address.strip():
        return {'zillow': False}
    zipcode = address.split()[-1]  # address.split()[-1].split('-')[0]
    zillow_data = ZillowWrap(ZWSID)
    print("zestimate for address:{}, zipcode:{}".format(address, zipcode))
    try:
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
    # except pyzillow.pyzillowerrors.ZillowError:
    #     return
    except Exception:
        print("Error while parsing zillow attributes for {}".format(address))
        return {'zillow': False}
    deep_search = GetDeepSearchResults(deep_search_response)
    # **************************************
    # GetZestimate
    # **************************************
    try:
        resp = zillow_data.get_zestimate(deep_search.zillow_id)
    except Exception:
        print("Error while parsing zillow attributes for {}".format(address))
        return {'zillow': False}
    zestimate_result = GetZestimateDetails(resp)
    # pprint(zestimate_result.__dict__)
    zillow_res = {}
    for attr in zillow_attrs:
        key = 'zillow_bedrooms' if attr == 'bedrooms' else attr
        if attr in deep_search.__dict__:
            attr_value = deep_search.get_attr(attr)
            if attr_value:
                zillow_res[key] = attr_value
        elif attr in zestimate_result.__dict__:
            attr_value = zestimate_result.get_attr(attr)
            if attr_value:
                zillow_res[key] = attr_value
    zillow_res['zillow'] = True
    return zillow_res
Example #19
0
def call_zillow_api(address, zipcode):
    #YOUR_ZILLOW_API_KEY = 'X1-ZWz1ffghcdgzkb_a80zd' #[email protected]
    YOUR_ZILLOW_API_KEY = 'X1-ZWz19ktnpd1lor_67ceq'  #[email protected]
    zillow_data = ZillowWrapper(YOUR_ZILLOW_API_KEY)

    try:
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_response)
        print 'User input zillow_id = {}'.format(result.zillow_id)
    except:
        result = -9999

    return result
def getZillowData(address="1600 Pennsylvania Avenue NW", zipcode="20500"):

    global g_MyApiKey

    webResponse = ""

    zillowData = ZillowWrapper(g_MyApiKey)

    webResponse = zillowData.get_deep_search_results(address, zipcode)
    result = GetDeepSearchResults(webResponse)

    print(result.zestimate_percentile)

    return result
Example #21
0
def get_zillow_data(addr_list, zip_list):
    meta = "https://maps.googleapis.com/maps/api/streetview/metadata?"
    base = "https://maps.googleapis.com/maps/api/streetview?size=1200x800&"
    myloc = "C:\\Users\\sumukh210991\\Desktop\\Study\\Thesis\\popularity_score_for_houses\\python\\img"
    key = "&key=" + "AIzaSyC7-APuKb-aknoKymJdflh2jTC91HBe8rY"
    data = []
    count = 4960  # 4959
    for i in range(0, len(addr_list)):
        address = addr_list[i]
        zipcode = zip_list[i]
        zillow_data = ZillowWrapper("X1-ZWz1fpv5bng2rv_799rh"
                                    )  # nishant_masc 'X1-ZWz19gfhe5z8y3_8xo7s'
        # nishant:'X1-ZWz1fk2vm7fkln_8tgid';
        # sumukh: 'X1-ZWz1fijmr1w9hn_9fxlx';
        # Sumukh@sdsu: 'X1-ZWz19anfkueyob_77v70';
        # other: 'X1-ZWz1fpv5bng2rv_799rh';
        try:
            deep_search_response = zillow_data.get_deep_search_results(
                address, zipcode)
            result = GetDeepSearchResults(deep_search_response)

            loc = str(result.latitude) + "," + str(result.longitude)
            print(loc)
            params = {
                "location": loc,
                "width": "600",
                "height": "400",
                "key": "AIzaSyC7-APuKb-aknoKymJdflh2jTC91HBe8rY",
                "fov": "90",
                "pitch": "0",
                "heading": "1"
            }
            metaurl = meta + urllib.urlencode(params)
            MyUrl = base + urllib.urlencode(params)
            file_loc = "img/file" + (str(count)) + ".png"
            print(file_loc)
            status = requests.get(metaurl)
            if ("ZERO_RESULTS" in str(status.content)):
                print("NO CONTENT")
                continue
            else:
                count = count + 1
                res = urllib.urlretrieve(MyUrl, os.path.join(file_loc))
                data.append(result)
        except:
            # data.append("none")
            continue
    return (data)
Example #22
0
    def test_deep_search_results(self):
        """
        Tests parsing of deep_search results
        """

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

        set_get_deep_search_response(
            self.api_response_obj.get("get_deep_search_200_ok"))

        zillow_data = ZillowWrapper(api_key=None)
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_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.graph_data_link == "http://www.zillow.com/homedetails/" +
            "2114-Bigelow-Ave-N-Seattle-WA-98109/" +
            "48749425_zpid/#charts-and-data")
        assert result.map_this_home_link == "http://www.zillow.com/homes/48749425_zpid/"
        assert result.tax_year == "2018"
        assert result.tax_value == "1534000.0"
        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.last_sold_date == "11/26/2008"
        assert result.last_sold_price_currency == "USD"
        assert result.last_sold_price == "995000"
        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.zestimate_amount == "2001121"
        # assert result.zestimate_currency == 'USD'
        assert result.zestimate_last_updated == "05/28/2020"
        assert result.zestimate_value_change == "-16739"
        assert result.zestimate_valuation_range_high == "2121188"
        assert result.zestimate_valuation_range_low == "1881054"
        assert result.zestimate_percentile == "0"
Example #23
0
    def test_deep_search_results(self):
        """
        """

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

        zillow_data = ZillowWrapper(self.ZILLOW_API_KEY)
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_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.graph_data_link == \
            'http://www.zillow.com/homedetails/' + \
            '2114-Bigelow-Ave-N-Seattle-WA-98109/' + \
            '48749425_zpid/#charts-and-data'
        assert result.map_this_home_link == \
            'http://www.zillow.com/homes/48749425_zpid/'
        assert result.tax_year == '2013'
        assert result.tax_value == '995000.0'
        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.last_sold_date == '11/26/2008'
        assert result.last_sold_price_currency == 'USD'
        assert result.last_sold_price == '995000'
        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.zestimate_amount == '1433441'
        # assert result.zestimate_currency == 'USD'
        assert result.zestimate_last_updated == '01/06/2015'
        assert result.zestimate_value_change == '7838'
        assert result.zestimate_valuation_range_high == '1591120'
        assert result.zestimate_valuationRange_low == '1275762'
        assert result.zestimate_percentile == '0'
def get():
    lines = request.get_json(force=True)
    address_: str = lines['address']
    #predictants: List[float] = lines['predictands']
    # NOTE: TODO: edit in the TEST_REQUESTS notebook to ONLY SEND THE ADDRESS KEY.
    # # The predicands key _hasn't evne been being used_

    address, zipcode = addr_zip_split(address_)

    try:
        # doing this in try-except is crucial, because of the way zillow fails
        # when you give it an address that it doesn't want to / can't use
        zillow_data = ZillowWrapper(ZILLOW_KEY)
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_response)

        # ['home_size', 'bedrooms', 'bathrooms']
        predictants: List[float] = [
            result.home_size, result.bedrooms, result.bathrooms
        ]

        valuation: float = rfr.model.predict(np.array([predictants]))[0]

        outdat = {
            'upper_lower_bound_by_city': cityfunc(address),
            'valuation': valuation
        }

        response = app.response_class(response=json.dumps(outdat),
                                      status=200,
                                      mimetype='application/json')

        print(outdat)

        return response

    except ZillowError as e1:
        message = "address given not available in zillow api. Please try another address"
        print(message)

        return app.response_class(response=json.dumps({"FAIL": message}),
                                  status=200,
                                  mimetype='application/json')
Example #25
0
def find_zillow_by_zip(address, zip):
    zillow_data = ZillowWrapper("X1-ZWz1fe5w83qcjv_70ucn")
    try:
        deep_search_response = zillow_data.get_deep_search_results(
            address, zip)
        result = GetDeepSearchResults(deep_search_response)
        zid = result.zillow_id
        #print zid
        url = 'http://www.zillow.com/webservice/GetZestimate.htm?zws-id=X1-ZWz1fe5w83qcjv_70ucn&zpid=' + zid
        #print url
        page = requests.get(url)
        tree = html.fromstring(page.content)
        prices = tree.xpath('//amount/text()')
        zillow = [zid, prices[0]]
        return zillow

    except ZillowError as err:
        print("No Zillow Found!")
        return ['', '']
def get_rent_zest(address, zip):
    deep_search_response = zillow_data.get_deep_search_results(
        address, zipcode)
    result = GetDeepSearchResults(deep_search_response)
    print(result.zestimate_amount)
    zpid = result.zillow_id
    rentzestimate = True
    # defining a params dict for the parameters to be sent to the API
    PARAMS = {'zws-id': zws_id, 'zpid': zpid, 'rentzestimate': rentzestimate}
    # api-endpoint
    URL = "http://www.zillow.com/webservice/GetZestimate.htm"

    r = requests.get(url=URL, params=PARAMS)
    print(r.content)

    data = r.content.decode('utf-8')
    xmltodict_data = xmltodict.parse(data)
    items = list(xmltodict_data.items())

    def listRecursive(d, key, path=None):
        if not path: path = []
        for k, v in d.items():
            if isinstance(v, OrderedDict):
                for path, found in listRecursive(v, key, path + [k]):
                    yield path, found
            if k == key:
                yield path + [k], v

    for path, found in listRecursive(xmltodict_data, 'rentzestimate'):
        rent_zest = found

    amount = dict(rent_zest)
    cur_rent_zestimate = dict(amount['amount'])['#text']
    low_rent_zestimate = dict(dict(amount['valuationRange'])['low'])['#text']
    high_rent_zestimate = dict(dict(amount['valuationRange'])['high'])['#text']
    return {
        'current': cur_rent_zestimate,
        'low': low_rent_zestimate,
        'high': high_rent_zestimate
    }
def zillow_query(address, zipcode, key='YOURAPIKEYHERE'):
    """Function for obtaining data for a given address location

    Args:
        address (str): street address

        zipcode (str): zipcode corresponding with street address

        key (str): (default='YOURAPIKEYHERE') zillow api key

    Returns:
        returns a GetDeepSearchResults object which has following attributes available:
            'zillow_id'
            'home_type'
            'home_detail_link'
            'graph_data_link'
            'map_this_home_link'
            'latitude'
            'longitude'
            'tax_year'
            'tax_value'
            'year_built'
            'property_size'
            'home_size'
            'bathrooms'
            'bedrooms'
            'last_sold_date'
            'last_sold_price'
            'zestimate_amount'
            'zestimate_last_updated'
            'zestimate_value_change'
            'zestimate_valuation_range_high'
            'zestimate_valuationRange_low'
            'zestimate_percentile'
    """
    zillow_data = ZillowWrapper(key)
    deep_search_response = zillow_data.get_deep_search_results(
        address, zipcode)
    result = GetDeepSearchResults(deep_search_response)
    return result
Example #28
0
def get_data_from_zillow_api(address, zipcode, API_key):
    """
    ##################################################################
    ###    This code generates public transportation to a location
    ###    using Google's Directions API.
    ###    _________________________________________________________
    ###    INPUT:    address - Redfin Raw Source Data "Address, City, State"
    ###              zipcode - Redfin Raw Source Data "Zipcode" 
    ###              API_key - Google API (string)
    ###    OUTPUT:   PyZillow class 
    ###################################################################
    """
    # Load Zillow API
    zillow_data = ZillowWrapper(API_key)

    try:
        deep_search_response = zillow_data.get_deep_search_results(
            address, zipcode)
        result = GetDeepSearchResults(deep_search_response)
    except:
        result = None
    return (result)
def get_house_info(address, unit, zipcode, latitude, longitude):
    house_info = []
    try:
        # if unit value exists, do not make zillow api call
        if does_unit_exist(unit):
            house_info.extend(
                ('', address, '', '', '', '', '', '', '', '', '', '', ''))
        elif math.isnan(
                zipcode
        ):  # if zipcode info isn't available, do not make zillow api call
            house_info.extend(
                ('', address, '', '', '', '', '', '', '', '', '', '', ''))
        else:  # make zillow api call
            zipcode = str(int(zipcode))
            deep_search_response = zillow_data.get_deep_search_results(
                address, zipcode)
            result = GetDeepSearchResults(deep_search_response)

            zillow_id = result.zillow_id
            home_type = result.home_type
            home_detail_link = result.home_detail_link
            graph_data_link = result.graph_data_link
            year_built = result.year_built
            sqft = result.home_size
            lot = result.property_size
            bed = result.bedrooms
            bath = result.bathrooms
            last_sold_date = result.last_sold_date
            last_sold_price = result.last_sold_price

            house_info.extend((zillow_id, address, zipcode, latitude,
                               longitude, sqft, lot, bed, bath, home_type,
                               year_built, last_sold_date, last_sold_price))
    except:
        print(address + ': exception')
        return []

    return house_info
Example #30
0
def Get_Zillow_Data(address, zipcode, Zkey):

	from pyzillow.pyzillow import ZillowWrapper, GetDeepSearchResults, GetUpdatedPropertyDetails

	zillow_data = ZillowWrapper(Zkey)
	deep_search_response = zillow_data.get_deep_search_results(address=address, zipcode=zipcode)
	result = GetDeepSearchResults(deep_search_response)
	#updated_property_details_response = zillow_data.get_updated_property_details(result.zillow_id)
	#updatedresult = GetUpdatedPropertyDetails(updated_property_details_response)
	resultdict = {'Zillow ID':result.zillow_id,
				  'Zestimate':result.zestimate_amount,
				  'Lot Size':result.property_size,
				  'Square Feet':result.home_size,
				  'Bedrooms':result.bedrooms,
				  'Bathrooms':result.bathrooms,
				  'Year Built':result.year_built,
				  'Home Type':result.home_type,
				  'Listing Link':result.home_detail_link}#,
				  #'Floors':updatedresult.num_floors,
				  #'Parking':updatedresult.parking_type,
				  #'Home Info':updatedresult.home_info,
				  #'School Info':updatedresult.school_district,
				  #'Neighborhood Info':updatedresult.neighborhood}
	return resultdict
__author__ = 'jstannard'

from pyzillow.pyzillow import ZillowWrapper, GetDeepSearchResults, GetUpdatedPropertyDetails

address = '1760 Ardmore St NE'
zipcode = '32907'
# zillow_id = '43504943'


zillow_data = ZillowWrapper('X1-ZWz1a2ngha04jv_8s1xw')
deep_search_response = zillow_data.get_deep_search_results(address, zipcode)
result = GetDeepSearchResults(deep_search_response)
#
# response = zillow_data.ge
# print(result.get_attr('home_info'))
# result = GetUpdatedPropertyDetails(response)

print(result.get_attr('home_size'))
print(result.get_attr('bedrooms'))
print(result.get_attr('home_type'))
print(result.get_attr('zestimate_amount'))
print(result.get_attr('zillow_id'))
list10 = []
for item in list1:
    text = item.text
    list10.append(text)
list11 = []
for item in list2:
    text = item.text
    list11.append(text)
zillow_data = ZillowWrapper('X1-ZWz1a2ngha04jv_8s1xw')

list6 = []
list7 = []
list9 = []
for i in range (0,len(list10)):
    deep_search_response = zillow_data.get_deep_search_results(list10[i], list11[i])
    result = GetDeepSearchResults(deep_search_response)
    #print(result.get_attr('home_detail_link'))

    url2 = result.get_attr('home_detail_link')
    response = requests.get(url2)
    html = response.content

    soup2 = BeautifulSoup(html)
    list4 = soup2.findAll('ul', { 'class' : 'zsg-list_square zsg-lg-1-3 zsg-md-1-2 zsg-sm-1-1'})
    list8 = soup2.findAll('div', {'class':'zsg-lg-2-3 zsg-sm-1-1 hdp-header-description'})
    list5 = soup2.findAll('div', {'class':  'main-row  home-summary-row'})
    for item in list4:
        text = item.text
        list6.append(text)
    for item in list5:
        text = item.text