2个月前 (04-02) laical  ASP.Net
文章评分 0 次,平均分 0.0
  // 要访问的目标页面
    string targetUrl = "http://httpbin.org/ip";

    // 代理服务器(产品官网 www.16yun.cn)
    string proxyHost = "http://t.16yun.cn";
    string proxyPort = "6447";

    // 代理隧道验证信息
    string proxyUser = "16IXNGXO";
    string proxyPass = "366338";

    // 设置代理服务器
    WebProxy proxy = new WebProxy(string.Format("{0}:{1}", proxyHost, proxyPort), true);

    ServicePointManager.Expect100Continue = false;

    var request = WebRequest.Create(targetUrl) as HttpWebRequest;

    request.AllowAutoRedirect = true;
    request.KeepAlive = true;
    request.Method    = "GET";
    request.Proxy     = proxy;

    //request.Proxy.Credentials = CredentialCache.DefaultCredentials;

    request.Proxy.Credentials = new System.Net.NetworkCredential(proxyUser, proxyPass);

    // 设置Proxy Tunnel
    // Random ran=new Random();
    // int tunnel =ran.Next(1,10000);
    // request.Headers.Add("Proxy-Tunnel", String.valueOf(tunnel));

    //request.Timeout = 20000;
    //request.ServicePoint.ConnectionLimit = 512;
    //request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36";
    //request.Headers.Add("Cache-Control", "max-age=0");
    //request.Headers.Add("DNT", "1");

    //String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(proxyUser + ":" + proxyPass));
    //request.Headers.Add("Proxy-Authorization", "Basic " + encoded);

    using (var response = request.GetResponse() as HttpWebResponse)
    using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
    {
        string htmlStr = sr.ReadToEnd();
    }




//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

  
 

除特别注明外,本站所有文章均为铁匠运维网原创,转载请注明出处来自http://www.tiejiang.org/26436.html

关于

发表评论

暂无评论

切换注册

登录

忘记密码 ?

切换登录

注册

扫一扫二维码分享