I have a script that pulls data from Zillow into a google doc....see below. It has worked fine for a couple of years but recently stopped working. It appears to run but takes a long time and no data is populated. The Zillow ID is located in Column B of the active sheet and according to the script the Zestimate should be written in Column 48. I've replaced my ZWS-ID with "X1-XXXXXXXXX_XXXX"
Any help is greatly appreciated.
Thanks KIWI
function getZillowEstimates() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var specificRow = ""
var endRow;
if(specificRow == "")
{
specificRow = 1;
endRow = numRows;
}
else
{
specificRow = specificRow - 1;
endRow = specificRow;
}
for (var i = specificRow; i <= endRow; i++)
{
try
{
var row = values[i];
var response = UrlFetchApp.fetch("http://www.zillow.com/webservice/GetZestimate.htm?zws-id=X1-XXXXXXXXX_XXXX&zpid=" + row[1]);
var xmlDoc = XmlService.parse(response.getContentText());
var documentElement = xmlDoc.getRootElement();
var destinationRange = sheet.getRange(i + 1, 48, 1, 1);
if( null != documentElement )
{
var responseElement = documentElement.getChild("response");
if (null != responseElement)
{
var zestimateElement = responseElement.getChild("zestimate");
if( null != zestimateElement)
{
var amountElement = zestimateElement.getChild("amount");
if( null != amountElement)
{
var rowValue = [];
var cellValue = [];
cellValue.push(amountElement.getText());
}
}
}
}
else
{
cellValue.push("Not Found");
}
rowValue.push(cellValue);
destinationRange.setValues(rowValue);
}
catch(exception)
{
}
}
};
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var menuItems = [
{name: 'Get ZEstimate', functionName: 'getZillowEstimates'},
];
spreadsheet.addMenu('Zestimates', menuItems)
};