文章详情
接入指南 - 代码 - C#
// 要访问的目标页面
string targetUrl = "http://www.quqiquqi.com/test";
// 请求切换IP(仅短效版、长效版用。动态版每次请求自动切换,无需指定)
//string targetUrl = "http://www.quqiquqi.com/switch-ip";
// 查看当前隧道出口IP信息
//string targetUrl = "http://www.quqiquqi.com/current-ip";

// 代理服务器
string proxyHost = "http://tunnel.quqiquqi.com";
string proxyPort = "8600";

// 代理隧道验证信息
string proxyUser = "U123456789";
string proxyPass = "P123456789";

// 设置代理服务器
var proxy         = new WebProxy();
proxy.Address     = new Uri(string.Format("{0}:{1}", proxyHost, proxyPort));
proxy.Credentials = new NetworkCredential(proxyUser, proxyPass);

ServicePointManager.Expect100Continue = false;

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

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

//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");

using (var response = request.GetResponse() as HttpWebResponse)
using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
    string htmlStr = sr.ReadToEnd();
}
发布时间:2021-10-02

在线客服