求个有效的代理主机ip

ld191474639 2012-09-16 05:36:25
小弟在写网络爬虫,现在是遇到HttpHost h=new HttpHost("192.168.0.1",5614);
就是这个Host链接被拒绝,求个有效的
...全文
107 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ld191474639 2012-09-16
  • 打赏
  • 举报
回复
try{
HttpClient http=new DefaultHttpClient();
http.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost("202.108.5.1",5461));
HttpGet hg=new HttpGet("http://www.baidu.com/");
HttpResponse hr=http.execute(hg);
HttpEntity he=hr.getEntity();
if(he!=null){
String charset=EntityUtils.getContentCharSet(he);
InputStream is=he.getContent();
BufferedReader br=new BufferedReader(new InputStreamReader(is,charset));
String line=null;
while((line=br.readLine())!=null){
System.out.println(line);
}
is.close();
}
http.getConnectionManager().shutdown();
}catch(Exception e){
e.printStackTrace();
}

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧