Skip to content

Instantly share code, notes, and snippets.

@groundwater
Created April 29, 2012 04:29
Show Gist options
  • Save groundwater/2533023 to your computer and use it in GitHub Desktop.
Save groundwater/2533023 to your computer and use it in GitHub Desktop.
Fetch Content from Crunchbase in Google Spreadsheets

Instructions

  1. Create a script in Google Spreadsheets and paste the code.
  2. Create a trigger to run fetch whenever the document is edited
  3. Go to the spreadsheet, type a company name in the A column and hit enter

The script should take the name, fetch data from crunchbase and insert a row with the requested data.

var ss = SpreadsheetApp.getActive();
function getFeed(name, feedurl){
var feed = UrlFetchApp.fetch(feedurl);
var jsonString = feed.getContentText();
var json = Utilities.jsonParse(jsonString);
var sheet = ss.getActiveSheet();
var row = sheet.getActiveCell().getRow();
var values = []; // json data to be inserted into row
sheet.appendRow(values);
}
function fetch() {
if (ss.getActiveSheet().getName() == "Sheet1"){
var cell = ss.getActiveCell().getValue();
var row = ss.getActiveCell().getRow();
ss.deleteRow(row);
getFeed(cell, "http://api.crunchbase.com/v/1/company/" + cell + ".js");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment