Wednesday, April 25, 2012

Locating All details of IP Adress (Method 2)

In my previous post I have explained about how to locate the IP Address country it self. Please go through the before post : In Yhis post I am going to Explain about how to locate the whole address of the IP. To do this first download the htmlagilitypack from the following URL : Which will help us to read the html content.
After Downloading then create a new project and add the downloaded dll in to our solution.e; Right click on references and add the dll.

Then add the New Aspx page with the following code:

<html xmlns="">
<head id="Head1" runat="server">
    <style type="text/css">
        font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;  
        background-color: #ffffff;
        color: #4f6b72;     
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <asp:Panel ID="panelLoc" runat="server">
                    <asp:TextBox ID="txtIP" runat="server"></asp:TextBox>
                    <asp:Button ID="btnGetLoc"
                        runat="server" Text="Get IP Details" onclick="btnGetLoc_Click" />
                    <br />
                    <div id="kk" runat="server"></div>

        <asp:UpdateProgress ID="updProgress"
            <img alt="progress" src="images/progress.gif"/>       


After creating Aspx page then code behind and add the following namespaces.

using HtmlAgilityPack;

Then add the following code in the code behind file :

protected void Page_Load(object sender, EventArgs e)


        protected void btnGetLoc_Click(object sender, EventArgs e)
            String url = String.Empty;

            if (txtIP.Text.Trim() != String.Empty)
                url = String.Format("{0}", txtIP.Text.Trim());
                HtmlWeb hw = new HtmlWeb();
                HtmlDocument doc = hw.Load(url);
                HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@align='center']/table[@cellspacing='0'][@width='650']");
                kk.InnerHtml = node.OuterHtml;

Here I am sending the request to and downloading the data and then I am formating the output table in the Div kk.



No comments:

Post a Comment