Forked from nickboyce/instagram_count_to_googe_sheet_2.js
Created
October 8, 2019 17:41
-
-
Save bran921007/629c0c83d7837302008082d8067e8935 to your computer and use it in GitHub Desktop.
This file contains hidden or 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