package comtantest;
import javaioBufferedInputStream;
import javaioIOException;
import javanetURL;
import javanetURLConnection;
import orgapachelog4jLogger;
public class TestProxyIp {
private static final Logger log = LoggergetLogger(TestProxyIpclass);
public static void main(String[] args) throws IOException {
SystemsetProperty("httpmaxRedirects", "50");
SystemgetProperties()setProperty("proxySet", "true");
// 如果不设置,只要代理IP和代理端口正确,此项不设置也可以
String ip = "59175192126";
ip = "221214180130";
ip = "12222417191";
ip = "58221213166";
ip = "2021061636";
ip = "121819134";
ip = "22220824230";
ip = "2192399085";
ip = "6031177188";
SystemgetProperties()setProperty("httpproxyHost", ip);
SystemgetProperties()setProperty("httpproxyPort", "3128");
//确定代理是否设置成功
loginfo(getHtml("http://wwwipcn/"));
//loginfo(getHtml("http://20140507ip138com/icasp"));
}
private static String getHtml(String address){
StringBuffer html = new StringBuffer();
String result = null;
try{
URL url = new URL(address);
URLConnection conn = urlopenConnection();
connsetRequestProperty("User-Agent","Mozilla/40 (compatible; MSIE 70; NT 51; GTB5; NET CLR 2050727; CIBA)");
BufferedInputStream in = new BufferedInputStream(conngetInputStream());
try{
String inputLine;
byte[] buf = new byte[4096];
int bytesRead = 0;
while (bytesRead >= 0) {
inputLine = new String(buf, 0, bytesRead, "UTF-8");
/if (!""equals(inputLine)) {
Systemoutprintln(inputLine);
}/
htmlappend(inputLine);
bytesRead = inread(buf);
inputLine = null;
}
buf = null;
}finally{
inclose();
conn = null;
url = null;
}
//result = new String(htmltoString()trim()getBytes("ISO-8859-1"), "UTF-8")toLowerCase();
//result=new String(htmltoString()trim()getBytes("ISO-8859-1"), "GBK");
}catch (Exception e) {
eprintStackTrace();
return null;
}/finally{
html = null;
}/
return htmltoString();
}
}
但是找不到有用的动态ip。
以上就是关于Java 编写IP动态代理全部的内容,包括:Java 编写IP动态代理、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)