您的位置:首页 > 新闻资讯 >文章内容
使用代理IP制作刷票系统(中)
来源:互联网 作者:admin 时间:2019-09-25 10:53:02

  使用代理IP制作刷票系统(上)文章里面已经将系统的框架介绍完毕了,剩下的就是重头戏,代码部分了。由于代码部分的篇幅占据比较长,为了优化大家的阅读,机灵代理会划分为两个部分,这样大家就不用一下子受到大段大段代码的冲击了。好了,立马进入正题,看看代理IP是怎么在系统中起作用的吧。


使用代理IP制作刷票系统


  5、系统代码


  1、IpInfo.java


  package com.hust.grid.leesf.bean;

  public class IpInfo {

  public IpInfo(String ipAddress, int port, String location,

  String anonymousType, String type, String confirmTime) {

  this(ipAddress, port, location, anonymousType, type, confirmTime, null,

  null);

  }

  public IpInfo(String ipAddress, int port, String location,

  String anonymousType, String type, String confirmTime,

  String getPostSupport, String responseSpeed) {

  this.ipAddress = ipAddress;

  this.port = port;

  this.location = location;

  this.anonymousType = anonymousType;

  this.type = type;

  this.confirmTime = confirmTime;

  this.getPostSupport = getPostSupport;

  this.responseSpeed = responseSpeed;

  }

  public String getIpAddress() {

  return ipAddress;

  }

  public void setIpAddress(String ipAddress) {

  this.ipAddress = ipAddress;

  }

  public int getPort() {

  return port;

  }

  public void setPort(int port) {

  this.port = port;

  }

  public String getLocation() {

  return location;

  }

  public void setLocation(String location) {

  this.location = location;

  }

  public String getAnonymousType() {

  return anonymousType;

  }

  public void setAnonymousType(String anonymousType) {

  this.anonymousType = anonymousType;

  }

  public String getType() {

  return type;

  }

  public void setType(String type) {

  this.type = type;

  }

  public String getConfirmTime() {

  return confirmTime;

  }

  public void setConfirmTime(String confirmTime) {

  this.confirmTime = confirmTime;

  }

  public String getGetPostSupport() {

  return getPostSupport;

  }

  public void setGetPostSupport(String getPostSupport) {

  this.getPostSupport = getPostSupport;

  }

  public String getResponseSpeed() {

  return responseSpeed;

  }

  public void setResponseSpeed(String responseSpeed) {

  this.responseSpeed = responseSpeed;

  }

  @Override

  public boolean equals(Object anthor) {

  if (this == anthor) {

  return true;

  }

  if (anthor == null || getClass() != anthor.getClass()) {

  return false;

  }

  IpInfo ipInfo = (IpInfo) anthor;

  return (this.ipAddress.equals(ipInfo.ipAddress)

  && this.port == ipInfo.port

  && this.location.equals(ipInfo.location)

  && this.anonymousType.equals(ipInfo.anonymousType)

  && this.type.equals(ipInfo.type) && this.confirmTime

  .equals(ipInfo.confirmTime))

  && this.getPostSupport.equals(ipInfo.getPostSupport)

  && this.responseSpeed.equals(ipInfo.responseSpeed);

  }

  @Override

  public int hashCode() {

  int hash = 5;

  hash = 89 * hash

  + (this.ipAddress != null ? this.ipAddress.hashCode() : 0);

  hash = 89 * hash + this.port;

  hash = 89 * hash

  + (this.location != null ? this.location.hashCode() : 0);

  hash = 89

  * hash

  + (this.anonymousType != null ? this.anonymousType.hashCode()

  : 0);

  hash = 89 * hash + (this.type != null ? this.type.hashCode() : 0);

  hash = 89 * hash

  + (this.confirmTime != null ? this.confirmTime.hashCode() : 0);

  hash = 89

  * hash

  + (this.getPostSupport != null ? this.getPostSupport.hashCode()

  : 0);

  hash = 89

  * hash

  + (this.responseSpeed != null ? this.responseSpeed.hashCode()

  : 0);

  return hash;

  }

  @Override

  public String toString() {

  return "ipAddress = " + ipAddress + ", port = " + port + ", localtion = "

  + location + ", anonymousType = " + anonymousType + ", type = "

  + type + ", confirmTime = " + confirmTime + ", getPostSupport = "

  + getPostSupport + ", responseSpeed = " + responseSpeed;

  }

  private String ipAddress;

  private int port;

  private String location;

  private String anonymousType;

  private String type;

  private String confirmTime;

  private String getPostSupport;

  private String responseSpeed;

  }


  2、Vote.java


  package com.hust.grid.leesf.entrance;

  import java.util.Timer;

  import java.util.concurrent.BlockingQueue;

  import java.util.concurrent.LinkedBlockingQueue;

  import com.hust.grid.leesf.bean.IpInfo;

  import com.hust.grid.leesf.thread.IPCollectTask;

  import com.hust.grid.leesf.thread.VoteThread;

  public class Vote {

  private BlockingQueue<IpInfo> ipInfoQueue;

  private IPCollectTask ipCollectTask;

  private VoteThread voteThread;

  public Vote() {

  ipInfoQueue = new LinkedBlockingQueue<IpInfo>();

  ipCollectTask = new IPCollectTask(ipInfoQueue);

  voteThread = new VoteThread(ipInfoQueue);

  }

  public void vote() {

  Timer timer = new Timer();

  long delay = 0;

  long period = 1000 * 60 * 60;

  // 每一个小时采集一次ip

  timer.scheduleAtFixedRate(ipCollectTask, delay, period);

  // 开启投票任务

  voteThread.start();

  }

  public static void main(String[] args) {

  Vote vote = new Vote();

  vote.vote();

  }

  }


  剩下的代码部分,机灵代理会在后续继续分享,请锁定更新。


相关文章内容简介
推荐阅读
  • 27 2019-11
    SOCKS代理IP使用介绍

    在机灵代理的网上,大家可以看到很多代理IP的相关信息,机灵代理有HTTP代理以及SOCKS代理给用户挑选,那么使用SOCKS代理IP,我们需要了解些什么呢?

  • 09 2019-09
    反向代理如何获取真实IP?

    代理IP除了能够用于营销活动、爬虫工作之外,其实还有很多用途,不少大神开发了很多用途。如果你想知道在反向代理或者CDN情况下,想要获得真实的IP地址,要怎么进行操作,那就可不能错

  • 15 2020-09
    5种保护ip地址的方法

    局域网中IP地址被别人不小心占用的现象时有发生,严重影响了局域网的管理和维护效率;为了提高局域网管理和维护效率,有必要对随意修改IP地址的行为进行限制。为此,本文为大家提供了5

  • 28 2020-06
    怎么利用ip代理上网

    ip代理就像是一个中转站,将你和你想要浏览的网站链接在一起,节省时间又方便快捷,轻松改变现有的上网模式,无论在任何时候想要轻松快乐的上网,那么代理ip绝对是您的最佳选择。

  • 14 2019-06
    遇到封IP用代理ip访问

    遇到封IP用代理ip访问,这是最有效的方法了,不管是做什么,总之如果都是IP限制,封IP,换个IP就能解决问题了。

  • 20 2019-03
    如何获取国内高质量的代理IP?

    代理IP的来源比较多,一般大家都使用哪家的质量比较好?来源都有哪些?效果怎么样?如何获取国内高质量的代理IP?

在线咨询
大客户经理
大客户经理
1829380381
13316264505

大客户经理微信

微信公众号

微信公众号

回到顶部