1

I want to load HTML for IP protected website like https://www.homedepot.com/ this website can't be accessed in Pakistan.

and I want to get HTML Source. What should i do?

I am trying with this code given below.

public HtmlAgilityPack.HtmlDocument LoadHtml(string url)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31";
    request.AllowAutoRedirect = false;
    HtmlAgilityPack.HtmlDocument htmlDoc = null;
    //WebProxy myproxy = new WebProxy("198.12.118.99", 80);
    //myproxy.BypassProxyOnLocal = false;
    request.AllowAutoRedirect = true;
    //myproxy.Credentials = new NetworkCredential("dasani", "amazon1!");
    //request.Proxy = myproxy;

    try
    {
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        htmlDoc = new HtmlAgilityPack.HtmlDocument();
        htmlDoc.Load(response.GetResponseStream());
        response.Close();
    }
    catch (WebException ex)
    {
        ex.ToString();
        //MessageBox.Show(ex.ToString());
    }
    return htmlDoc;
}
James Z
  • 12,209
  • 10
  • 24
  • 44
Rizwan
  • 122
  • 1
  • 7
  • I think you will need to use a proxy just like you tried or connect your machine to some VPN (or i.e. Tor) that will allow you to bypass these restrictions – vhr Mar 12 '19 at 14:23
  • look here https://stackoverflow.com/questions/1962483/using-tor-as-proxy – vhr Mar 12 '19 at 14:24
  • Kindly tell me vpn code in c#...how to get out of there? – Rizwan Mar 13 '19 at 04:18
  • once you connect your machine to VPN you have an otpion to route the whole internet traffic through it. so you don't really need to change your code because it can be done on the OS level – vhr Mar 13 '19 at 09:06
  • Did you check the discussion @vhr have provided? – undetected Selenium Mar 13 '19 at 13:30
  • My work was Done using **Psiphon** exe. It changes my computer IP address mean local IP address. Thank's to all guys. – Rizwan Mar 15 '19 at 04:31

0 Answers0