Since my time was wasted, I am posting this. It will scrape the following information for a specified instagram username:
InstagramUser.cs:
Request.cs:
Usage:
- Amount of followers
- Whether or not they are verified
- Their username
- Their description
InstagramUser.cs:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InstagramScraper
{
class InstagramUser
{
public bool isVerified;
public int followers;
public string username;
public string description;
public void parsePage(string ua, string user)
{
using (Request r = new Request(ua))
{
string response = r.requestString("https://instagram.com/" + user);
parsePage(response);
}
}
public void parsePage(string response)
{
//Verified
string verified = "\"is_verified\":";
if (response.Contains(verified))
{
int startIndex = response.IndexOf(verified);
int endIndex = response.IndexOf(",", startIndex);
string verifiedVal = response.Substring(startIndex + verified.Length, (endIndex - (startIndex + verified.Length)));
isVerified = (verifiedVal == "true" ? true : false);
}
//Followers
string follower = "\"followed_by\":{\"count\":";
if (response.Contains(follower))
{
int startIndex = response.IndexOf(follower);
int endIndex = response.IndexOf("}", startIndex);
string follow = response.Substring(startIndex + follower.Length, (endIndex - (startIndex + follower.Length)));
followers = Int32.Parse(follow);
}
//Username
string name = "<meta property=\"og:url\" content=\"https://instagram.com/";
if (response.Contains(name))
{
int startIndex = response.IndexOf(name);
int endIndex = response.IndexOf("/", startIndex + name.Length);
string n = response.Substring(startIndex + name.Length, (endIndex - (startIndex + name.Length)));
username = n;
}
//Description
string bio = "\"biography\":\"";
if (response.Contains(bio))
{
int startIndex = response.IndexOf(bio);
int endIndex = response.IndexOf("\",", startIndex + bio.Length);
string desc = response.Substring(startIndex + bio.Length, (endIndex - (startIndex + bio.Length)));
description = desc;
}
}
}
}Request.cs:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace InstagramScraper
{
class Request : IDisposable
{
private string useragent;
private WebClient wc;
public Request(string ua)
{
useragent = ua;
wc = new WebClient();
wc.Headers.Add("User-Agent", ua);
wc.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
wc.Headers.Add("Accept-Language", "en-US,en;q=0.5");
//wc.Headers.Add("Connection", "close");
wc.Headers.Add("Cache-Control", "max-age=0");
}
public string requestString(string uri)
{
try {
string resp = wc.DownloadString(@uri);
return resp;
}
catch (Exception ex)
{
return ex.Message;
}
}
public void Dispose()
{
wc.Dispose();
}
}
}Usage:
Code
InstagramUser iu = new InstagramUser().parsePage("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)", "snoopdogg");
New to trading cryptocurrencies but don't know where to start? Join Binance here! Binance is my favourite exchange for cryptocurrencies w/ low fees.
![[Image: 793854efd3c9ee7d90ddd413ae9deed6.png]](https://i.gyazo.com/793854efd3c9ee7d90ddd413ae9deed6.png)
![[Image: 793854efd3c9ee7d90ddd413ae9deed6.png]](https://i.gyazo.com/793854efd3c9ee7d90ddd413ae9deed6.png)




![[Image: a2dac36451a435791d8ef98546adb8fc.png]](https://i.gyazo.com/a2dac36451a435791d8ef98546adb8fc.png)