Skip to content

Instantly share code, notes, and snippets.

@nickboyce
Last active October 8, 2019 17:41
Show Gist options
  • Save nickboyce/d6e7a720c87e395d61448810a821b481 to your computer and use it in GitHub Desktop.
Save nickboyce/d6e7a720c87e395d61448810a821b481 to your computer and use it in GitHub Desktop.
function initFollowerCount() {
// sets up sheet names and Instagram accounts
insertFollowerCount("sheet1", "kingandmcgaw");
insertFollowerCount("sheet2", "nickboyce");
}
function insertFollowerCount(sheetName, instagramAccountName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getInstagramFollowerCount(instagramAccountName)]);
}
function getInstagramFollowerCount(username) {
var url = "https://www.instagram.com/" + username + "/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.followed_by.count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment