|
用你的HttpHelper设置代理(110.4.12.171:80)访问下面的网址一直报 The remote server returned an error: (404) Not Found.
http://info.3g.qq.com/g/s?aid=index&from=wap3g&s_it=1&sid=00
不要IP能正常访问
后再自己写了个get方法- public static string SendGetRequest(string Url)
- {
- string message = string.Empty;
- try
- {
- HttpWebRequest request = (HttpWebRequest) WebRequest.Create(Url);
- request.Accept = "text/html, application/xhtml+xml, */*";
- request.UserAgent = "Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.10.229 Version/11.61";
- request.KeepAlive = true;
- request.ProtocolVersion = HttpVersion.Version11;
- WebProxy proxy = new WebProxy("110.4.12.171:80");
- request.Proxy = proxy;
- ServicePointManager.Expect100Continue = false;
- Stream responseStream = ((HttpWebResponse) request.GetResponse()).GetResponseStream();
- StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8"));
- message = reader.ReadToEnd();
- reader.Close();
- responseStream.Close();
- }
- catch (Exception exception)
- {
- message = exception.Message;
- }
- return message;
- }
复制代码 有时也会报The remote server returned an error: (404) Not Found. 但大多数情况下不会报错 求教育
纠结了好久一直没解决
我用java写了个 非常正常都没出现过404
[code=java]public static String sendGetRequest(String reqURL) {
String responseContent = null;
DefaultHttpClient httpClient =new DefaultHttpClient();
HttpHost proxy = new HttpHost("110.4.12.171", 80);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpGet httpGet = new HttpGet(reqURL);
try {
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (null != entity) {
responseContent = EntityUtils.toString(entity, "UTF-8");
EntityUtils.consume(entity);
}
httpGet.abort();
} catch (ClientProtocolException e) {
httpGet.abort();
} catch (ParseException e) {
httpGet.abort();
} catch (IOException e) {
httpGet.abort();
} finally {
httpClient.getConnectionManager().shutdown();
}
return responseContent;
}[/code]
这个代理是多验证的代理 必须用这个代理
求大神帮忙解决 java写的窗体各种不舒服 就帮忙纠结代理问题
|
|