package test;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* <b>类名称:</b>HttpConnet<br/> <b>类描述:</b><br/> <b>创建人:</b>ZhengJie<br/>
* <b>修改人:</b>ZhengJie<br/> <b>修改时间:</b>2012-5-25 下午05:42:37<br/> <b>修改备注:</b><br/>
*
* @version 1.2.0<br/>
*/
public class HttpConnet {
static int runCount=0;
public static void main(String[] args) {
// System.getProperties().setProperty("http.proxyHost", "140.224.122.182");
// System.getProperties().setProperty("http.proxyPort", "3128");
// System.getProperties().put( "proxySet", "true" );
// System.getProperties().put( "proxyHost", "140.224.122.182" );
// System.getProperties().put( "proxyPort", 8080);
//"http://www.yorkfcwr.com/FHandler.ashx?id=427&key=do-vote&memberid=427&t=0.2389311243314296"
//System.out.println(getHtml("http://www.ip138.com/ip2city.asp")); // 判断代理是否设置成功
URL url= HttpConnet.class.getResource("2.txt");
BufferedReader in=null;
List<String> adds=new ArrayList<String>();
try {
in = new BufferedReader(new FileReader( url.getFile().substring(1)));
String line = null;
while((line = in.readLine())!=null)
{
String http=line.split(" ")[0];
//System.out.println(http);
adds.add(http);
}
ExecutorService pool = Executors.newFixedThreadPool(2);
for (String string : adds) {
String[] addArr= string.split(":");
if(addArr==null || addArr.length<2)continue;
System.out.println(string);
String http=addArr[0];
int port=Integer.parseInt(addArr[1]);
HttpConnet.MyThread thread=new HttpConnet().new MyThread(http,port);
pool.execute(thread);
}
pool.shutdown();
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class MyThread extends Thread {
String url;
int port;
public MyThread(String url ,int port) {
this.url=url;
this.port=port;
}
@Override
public void run() {
// TODO Auto-generated method stub
super.run();
threadEvent();
}
private void threadEvent(){
for (int i = 0; i < 9; i++) {
try {
long date=new Date().getTime();
// System.out.println(getHtml2("http://www.ip138.com/ip2city.asp")); // 判断代理是否设置成功
String result=getHtml("http://www.yorkfcwr.com/FHandler.ashx?id=427&key=do-vote&memberid=427&t="+date,url,port);
if(!"{\"result\":\"1\",\"msg\":\"投票成功!\"}".equals(result)){
break;
}else{
runCount++;
System.out.println("runCount:"+runCount);
}
Thread.sleep(1000);
} catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
break;
}
}
}
}
private static String getHtml(String address,String http,int port) throws Exception {
StringBuffer html = new StringBuffer();
String result = null;
try {
URL url = new URL(address);
InetSocketAddress addr = new InetSocketAddress(http,port);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr); // http 代理
URLConnection conn = url.openConnection(proxy);
// URLConnection conn = url.openConnection();
conn.setRequestProperty(
"User-Agent",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 2.0.50727; CIBA)");
BufferedInputStream in = new BufferedInputStream(conn
.getInputStream());
try {
String inputLine;
byte[] buf = new byte[4096];
int bytesRead = 0;
while (bytesRead >= 0) {
inputLine = new String(buf, 0, bytesRead, "ISO-8859-1");
html.append(inputLine);
bytesRead = in.read(buf);
inputLine = null;
}
buf = null;
} finally {
in.close();
conn = null;
url = null;
}
result = new String(html.toString().trim().getBytes("ISO-8859-1"),
"UTF-8").toLowerCase();
} catch (Exception e) {
//e.printStackTrace();
throw e;
}
html = null;
return result;
}
private static String getHtml2(String address) {
StringBuffer html = new StringBuffer();
String result = null;
try {
URL url = new URL(address);
URLConnection conn = url.openConnection();
conn
.setRequestProperty(
"User-Agent",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 2.0.50727; CIBA)");
BufferedInputStream in = new BufferedInputStream(conn
.getInputStream());
try {
String inputLine;
byte[] buf = new byte[4096];
int bytesRead = 0;
while (bytesRead >= 0) {
inputLine = new String(buf, 0, bytesRead, "ISO-8859-1");
html.append(inputLine);
bytesRead = in.read(buf);
inputLine = null;
}
buf = null;
} finally {
in.close();
conn = null;
url = null;
}
result = new String(html.toString().trim().getBytes("ISO-8859-1"),
"gb2312").toLowerCase();
} catch (Exception e) {
e.printStackTrace();
return null;
}
html = null;
return result;
}
}
分享到:
相关推荐
自动快速投票,每次用不同的HTTP代理IP地址,在...自动将投票成功的IP地址排除在外,可防止重复投票,也可将无效的代理地址排除,支持多线程,测试过,效果很不错。可以基于现有代码的基础上进行优化,加入配置的功能。
此次升级地方有: 1:添加投票计时清零功能 2:添加投票地址是否提前访问功能 3:添加使用代理投票时循环次数设置(0表一直循环) 4:添加相关数据格式验证
VL免费全自动投票机绿色软件,无需安装,VL免费全自动投票机按网络方式可分为:adsl\固定ip\代理IP,附加ip过滤功能。 按投票控制区:投票间隔\拔号间隔\停止票数\ip票数 间隔均以毫秒为单位。 按投票方法:分析...
6、票盟投票软件智能自动识别用户所使用的网络,比如ADSL宽带(也就是直接连猫(modem))再者就是使用路由器或者使用代理服务器连接网络。 7、票盟投票软件详细的投票记录,可以记录下当前投票IP,投票状态,投票...
通过代理上网的网友只是极个别现象,因此本投票系统将忽略掉通过代理(X-Forwarded-For)上网的用户。 实际投票过程中查找和确认投票项需要时间,用户只能在打开投票首页并在三秒钟之后才能成功投票。 IP记录库仅保留...
2.通过代理上网的网友只是极个别现象,因此本投票系统将忽略掉通过代理(X-Forwarded-For)上网的用户。 3.实际投票过程中查找和确认投票项需要时间,用户只能在打开投票首页并在三秒钟之后才能成功投票。 4.IP记录...
2.通过代理上网的网友只是极个别现象,因此本投票系统将忽略掉通过代理(X-Forwarded-For)上网的用户。 3.实际投票过程中查找和确认投票项需要时间,用户只能在打开投票首页并在三秒钟之后才能成功投票。 4.IP记录...
全国各省市寻找代理,最好使用较大城市的,自动更换本机IP,辅助投票工具
1、IP封锁管理、代理IP安全过滤功能,上传文件管理,防SQl注入,脏话过滤功能 2、单选/多选切换,投票开关,验证码开关,有效时间功能 3、防刷开关,防刷时间,安全页面跳转功能 4、IP开关功能,有效时间控制,IP...
20.[修改] 投票开始以后,应该不能对投票选项进行修改 21.[修改] 配送方式过多超过6个则在发货的时候只能看到4个配送方式其他配送方式换行但是换行以后被文本框挡住的问题 22.[修改] 货到付款有可能没有付款而是先...
20.[修改] 投票开始以后,应该不能对投票选项进行修改 21.[修改] 配送方式过多超过6个则在发货的时候只能看到4个配送方式其他配送方式换行但是换行以后被文本框挡住的问题 22.[修改] 货到付款有可能没有...
○投票功能。 ○便捷的网站推广通道,加入了十余种搜索引擎的在线登记功能。 ○升级通告:后台自动显示商城系统官方网站最新动态消息。 ○登陆、留言、评论、取回密码,均加设验证码,有效防止恶意猜解密码、非法...
加强URL传送加密,问题验证,防外链接功能,代理IP检测加强功能,时间效验功能等,安全验证,CC防注,最大有效数控制,会员模块控制等,更多设置模块请使用商业版。 网址/admin/admin_login.asp 帐号:admin 管理...
○投票功能。 ○便捷的网站推广通道,加入了十余种搜索引擎的在线登记功能。 ○升级通告:后台自动显示商城系统官方网站最新动态消息。 ○登陆、留言、评论、取回密码,均加设验证码,有效防止恶意猜解密码、非法...
加强URL传送加密,问题验证,防外链接功能,代理IP检测加强功能,时间效验功能等,安全验证,CC防注,最大有效数控制,会员模块控制等,更多设置模块请使用商业版。 网址/admin/admin_login.asp 帐号:admin 管理...
加强URL传送加密,问题验证,防外链接功能,代理IP检测加强功能,时间效验功能等,安全验证,CC防注,最大有效数控制,会员模块控制等,更多设置模块请使用商业版。 网址/admin/admin_login.asp 帐号:admin 管理...
11.提供接口给用户或是代理商使用。 12.可以接爱迪生6.0/7.0网络版软件。(需要卡发接受系统支持) 13.短信发送速度快。提交十万条号码到服务器,只需要一分钟。 14.客户发送的号码可以随意打包下载。 15.设置短信发送...