string targetUrl =
"https://ip.hahado.cn/ip";
string proxyIp =
"219.151.125.106";
string proxyPort =
"31615";
string authKey =
"895314XY";
string password =
"24D6YB309ZCB";
WebProxy proxy =
new
WebProxy(string.Format("{0}:{1}", proxyIp, proxyPort),
true);
proxy.Credentials
=
new
NetworkCredential(authKey, password);
ServicePointManager.Expect100Continue
=
false;
var request =
WebRequest.Create(targetUrl)
as
HttpWebRequest;
request.AllowAutoRedirect
=
true;
request.KeepAlive
=
true;
request.Method
=
"GET";
request.Proxy
= proxy;
request.Timeout
=
10000;
request.ServicePoint.ConnectionLimit
=
16;
using
(var resp = request.GetResponse()
as
HttpWebResponse)
using
(var reader =
new
StreamReader(resp.GetResponseStream(),
Encoding.UTF8)){
string htmlStr = reader.ReadToEnd();
}
C#语言代码示例
最新推荐文章于 2024-04-30 14:31:32 发布