Last active
September 9, 2025 21:38
-
-
Save Austin1/70bb8dc52a0c76e1c7a956b2adf1584f to your computer and use it in GitHub Desktop.
Zillow Google Sheets Zestimate Scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getZillowUrl(address) { | |
| const baseUrl = "https://www.zillow.com/homes/"; | |
| const addressUrl = baseUrl + address.replace(/\s+/g, '-') + "/"; | |
| try { | |
| const response = UrlFetchApp.fetch(addressUrl); | |
| const content = response.getContentText(); | |
| // Look for any script tags that might contain the zpid | |
| const scriptRegex = /<script\b[^>]*>([\s\S]*?)<\/script>/gm; | |
| let scriptMatches; | |
| while ((scriptMatches = scriptRegex.exec(content)) !== null) { | |
| try { | |
| const jsonData = JSON.parse(scriptMatches[1]); | |
| // Extract the zpid from the JSON data | |
| const zpidRegex = /"zpid":(\d+)/; | |
| const zpidMatches = JSON.stringify(jsonData).match(zpidRegex); | |
| if (zpidMatches && zpidMatches[1]) { | |
| const zpid = zpidMatches[1]; | |
| const finalUrl = `${addressUrl}${zpid}_zpid/`; | |
| return finalUrl; | |
| } | |
| } catch (e) { | |
| // If parsing fails, continue to the next script tag | |
| continue; | |
| } | |
| } | |
| return "URL not resolved"; | |
| } catch (e) { | |
| return "Error fetching URL: " + e.toString(); | |
| } | |
| } | |
| function getZillowUrl_full(address, city, state) { | |
| const baseUrl = "https://www.zillow.com/homes/"; | |
| const addressUrl = baseUrl + address.replace(/\s+/g, '-') + '-' + city.replace(/\s+/g, '-') + '-' + state + "/"; | |
| try { | |
| const response = UrlFetchApp.fetch(addressUrl); | |
| const content = response.getContentText(); | |
| // Look for any script tags that might contain the zpid | |
| const scriptRegex = /<script\b[^>]*>([\s\S]*?)<\/script>/gm; | |
| let scriptMatches; | |
| while ((scriptMatches = scriptRegex.exec(content)) !== null) { | |
| try { | |
| const jsonData = JSON.parse(scriptMatches[1]); | |
| // Extract the zpid from the JSON data | |
| const zpidRegex = /"zpid":(\d+)/; | |
| const zpidMatches = JSON.stringify(jsonData).match(zpidRegex); | |
| if (zpidMatches && zpidMatches[1]) { | |
| const zpid = zpidMatches[1]; | |
| const finalUrl = `${addressUrl}${zpid}_zpid/`; | |
| return finalUrl; | |
| } | |
| } catch (e) { | |
| // If parsing fails, continue to the next script tag | |
| continue; | |
| } | |
| } | |
| return "URL not resolved"; | |
| } catch (e) { | |
| return "Error fetching URL: " + e.toString(); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Above is working right now to download zestimate. To use:
or