1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Any idea on how to combine various sheets/multiple number of followers into one big sheet?

Discussion in 'JavaScript' started by essig10, Jun 22, 2018.

  1. #1
    I have started a project where I will be adding my family and friends into spreadsheet posted on a website, tracking how many Instagram followers we gain each hour, each day, split into various sheets.

    I want my website to have various sheets & charts with names & details, updated hourly, daily, weekly, monthly & yearly. So far this Google Sheet script only feeds the date & time but doesn't replace. Does anyone know how to help?

    Google Sheet script:

    // the name of the sheet within your document
    var sheetName = "Sheet1";
    // the name of the Instagram account you want to track
    var instagramAccountName = "kingandmcgaw";

    function insertFollowerCount() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName(this.sheetName);
    accountdata = getInstagramData(this.instagramAccountName);
    sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), accountdata.followerCount]);
    };

    function getInstagramData(username) {
    var r = new RegExp('<script type="text\/javascript">' +
    '([^{]+?({.*profile_pic_url.*})[^}]+?)' +
    '<\/script>');
    var url = "https://www.instagram.com/" + username
    var source = UrlFetchApp.fetch(url).getContentText();
    var jsonStr = source.match(r)[2];
    var data = JSON.parse(jsonStr);
    console.log('data', data);
    var oldVariantOfData = data['entry_data']['ProfilePage'][0];
    console.log('oldVariantOfData', oldVariantOfData);

    return {
    followerCount : oldVariantOfData.graphql.user.edge_followed_by.count,
    followCount : oldVariantOfData.graphql.user.edge_follow.count,
    mediaCount : oldVariantOfData.graphql.user.edge_owner_to_timeline_media.count
    };
    }
     
    Last edited: Jun 22, 2018
    essig10, Jun 22, 2018 IP