htmlweb-scrapinginstagram

Grab Instagram followers and embed into a html webpage


Does anyone know how to grab the live Instagram follower count of a user? I want to embed the live count of a particular user into an HTML webpage but can not figure out how.

Would appreciate any help and tips.


Solution

  • This is an example for getting the user info for a user with id #1362124742 using the Instagram API and token, for more info on using the Instagram API checkout this blog post

    var token = '1362124742.7b33a8d.6613a3567f0a425f9852055b8ef743b7',
      container2 = document.getElementById('rudr_userinfo'),
      scrElement2 = document.createElement('script');
    
    window.mishaProcessResult2 = function(response) {
      container2.innerHTML = '<div><p>#' + response.data.id + '</p>' +
        '<p>' + response.data.counts.media + ' media ' + response.data.counts.followed_by + ' followers ' + response.data.counts.follows + ' follows</p>' +
        '</div>';
    }
    
    scrElement2.setAttribute('src', 'https://api.instagram.com/v1/users/self?access_token=' + token + '&callback=mishaProcessResult2');
    document.body.appendChild(scrElement2);
    * {
      color: #262626;
      background-color: #fafafa;
      font-size: 18px;
      font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
      font-weight: 300;
    }
    
    #rudr_userinfo {
      display: flex;
    }
    <ul id="rudr_userinfo"></ul>