我正在点击这个网址:
http://www.google.co.uk/search?q=online stores uk&hl=en&cr=countryUK%7CcountryGB&as_qdr=all&tbs=ctr:countryUK
基本上我得到了 ppcUrls,它在没有任何代理的情况下完美运行。
但是当我尝试使用互联网上可用的代理时:
http://proxy-list.org/en/index.php?pp=3128&pt=any&pc=any&ps=any&submit=Filter+Proxy
上面的链接不会以任何方式打开:|,我确实用 Internet Explorer 检查了 ipz 并且它打开了,但是在 HTTPWEBREQUEST 中,有时我得到503 服务器不可用,或者重定向太多
该链接不会以任何 ip 打开。
有什么建议吗?下面是我获取 HTML 函数:
public string getHtml(string url, string proxytmp)
{
string responseData = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "*/*";
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
request.Timeout = 60000;
request.Method = "GET";
if (proxies.Count > 0)
{
try
{
int customIP = 0;
int port = 0;
string ip = string.Empty;
string[] splitter = proxytmp.Split(':');
if (splitter.Length > 0)
{
ip = splitter[0].ToString();
port = Convert.ToInt32(splitter[1].ToString());
}
WebProxy proxy = new WebProxy(ip, port);
request.Proxy = proxy;
}
catch (Exception exp)
{
}
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(responseStream);
responseData = myStreamReader.ReadToEnd();
}
response.Close();
}
catch (System.Exception e)
{
responseData = e.ToString();
}
return responseData;
}
更新
当我使用与 Internet Explorer 相同的代理时,Url 会打开,所以一定有办法。但我无法弄清楚。
谢谢