2016-06-30 7 views
-1

私はZillowのデータをGoogleドキュメントにプルするスクリプトを持っています....下記を参照してください。それは数年の間うまくいっていますが、最近は動作を停止しました。これは実行されているように見えますが、時間がかかり、データが入力されません。 Zillow IDはアクティブシートのB欄にあり、スクリプトに従ってZestimateを48桁目に記入してください。ZWS-IDを「X1-XXXXXXXXX_XXXX」に置き換えましたZillowとGoogle Script

ご協力いただきまして誠にありがとうございます。それが働いている 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) 
}; 
+0

ようこそ[so]。 [ツアー]とチェックアウト[質問]をしてください。 –

答えて

0

今日

感謝。昨日のスクリプトは6分、今日は1.6秒かかりました。私はZillowまたはAPIに問題があったと推測しています。