Results 1 to 3 of 3

VBA Code to Pull Zillow Comps

Threaded View

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    VBA Code to Pull Zillow Comps

    Hi, I am trying to pull multiple comps for a specific property using Zillow API's. However, there are multiple comps in the XML file associated with the specific property, and my code keeps pulling the same 2 or 3 property data from the URL, how should it be coded it to move onto the next <comps>? Any help would be appreciated.

    Here is an example XML file:

    http://www.zillow.com/webservice/Get...33642&count=20

    And corresponding code I'm using, which has been copied and edited from some other users on this site:
      URL = "http://www.zillow.com/webservice/GetDeepComps.htm?zws-id=" & ZWSID & "&zpid=" & rowZpid & "&count=" & Count
        
            'Open XML page
            Set xmldoc = New MSXML2.DOMDocument60
            xmldoc.async = False
            
            ' Check XML document is loaded
            If xmldoc.Load(URL) Then
            
                Set xmlMessage = xmldoc.SelectSingleNode("//message/text")
                Set xmlMessageCode = xmldoc.SelectSingleNode("//message/code")
                
                ' Check for an error message
                If xmlMessageCode.Text <> 0 Then
                
                    ' Return error message
                    WS.Range(ErrorMessage & I) = xmlMessage.Text
                    
                Else
                    ' Get XML data from Zillow
                    Set xmlHomeDetails = xmldoc.SelectSingleNode("//response/properties/comparables/comp/links/homedetails")
                           
                    ' Push data to spreadsheet
                    If xmlHomeDetails Is Nothing Then
                        WS.Range(HomeDetails & I) = "No home details available"
                    Else
                        WS.Range(HomeDetails & I).Formula = "=HYPERLINK(""" & xmlHomeDetails.Text & """,""Zillow Details"")"
                    End If
                  
                    ' Retrieve Street address, ZIP code ,City
                    Set xmlStreetAddress = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/street")
                    Set xmlZipCode = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/zipcode")
                    Set xmlCity2 = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/city")
                    ' Push data to spreadsheet
                    If xmlStreetAddress Is Nothing Then
                        WS.Range(StreetAddress & I) = "N/A"
                    Else
                    WS.Range(StreetAddress & I) = xmlStreetAddress.Text
                    End If
                    
                    If xmlZipCode Is Nothing Then
                        WS.Range(ZipCode & I) = "N/A"
                    Else
                    WS.Range(ZipCode & I) = xmlZipCode.Text
                    End If
                    
                    If xmlCity2 Is Nothing Then
                    WS.Range(City2 & I) = "N/A"
                    Else
                    WS.Range(City2 & I) = xmlCity2.Text
                    End If
                    
                    ' Retrieve Beds & Baths
                    Set xmlBed = xmldoc.SelectSingleNode("//response/properties/comparables/comp/bedrooms")
                    Set xmlBath = xmldoc.SelectSingleNode("//response/properties/comparables/comp/bathrooms")
                    ' Push data to spreadsheet
                    If xmlBed Is Nothing Then
                        WS.Range(Bed & I) = "N/A"
                    Else
                    WS.Range(Bed & I) = xmlBed.Text
                    End If
                    
                    If xmlBath Is Nothing Then
                        WS.Range(Bath & I) = "N/A"
                    Else
                    WS.Range(Bath & I) = xmlBath.Text
                    End If
    Last edited by Leith Ross; 11-12-2014 at 04:12 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pull zestimate from zillow with address and zip code
    By tiderider03 in forum Excel Programming / VBA / Macros
    Replies: 62
    Last Post: 09-26-2020, 03:56 PM
  2. VBA script to pull "ZEstimates" from Zillow.com
    By Veradusit in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-11-2019, 12:50 AM
  3. [SOLVED] Zillow xml API extraction
    By sdgenxr in forum Excel Programming / VBA / Macros
    Replies: 45
    Last Post: 06-30-2016, 07:22 PM
  4. VBA for Webscraping Zillow
    By use_excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2014, 12:15 PM
  5. Need to pull data from zillow into excel file.
    By jtaylor13 in forum Excel General
    Replies: 11
    Last Post: 11-06-2012, 08:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1