pulls data from YQL and puts in a spreadsheet
This file contains 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 pullData() { | |
//select * from yahoo.finance.quote where symbol in ("YHOO","AAPL","GOOG","MSFT") | |
var url="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"; | |
var response = UrlFetchApp.fetch(url); | |
var json=JSON.parse(response.getContentText()); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheets()[0]; | |
var quotes=json.query.results.quote; | |
for(var i=0;i<quotes.length;i++){ | |
col=i+1; | |
sheet.getRange('a'+col).setValue(quotes[i].Name); | |
sheet.getRange('b'+col).setValue(quotes[i].LastTradePriceOnly); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment