Last active
October 8, 2019 17:41
-
-
Save nickboyce/d6e7a720c87e395d61448810a821b481 to your computer and use it in GitHub Desktop.
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 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