Home > Uncategorized > Find All Websites on a Webserver in C#

Find All Websites on a Webserver in C#

This is a handy script that can tell you how many sites are hosted on an IP address.  It uses  the Bing API, so it basically asks bing if it knows of sites on that IP address. This means that they have to be listed in bing, i.e. with public access.

 

 

 public static int SitesOnIP(string ip)
        {
            string url = "http://api.search.live.net/json.aspx?";
            url += "Appid=92B665B5421E197DC762503859279DFEBBE0B998";
            url += "&query=IP:" + ip;
            url += "&sources=web&web.count=50";
            // "Web":{"Total":31900
            string strRegex = @"Web....Total..(?<Count>\d+)";
            WebClient web = new WebClient();
            string strJson = web.DownloadString(url);
            string strCount = Regex.Match(strJson, strRegex).Groups["Count"].Value;
            return Convert.ToInt32(strCount);
        }
Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: