您的位置:首页 > 新闻资讯 >文章内容
使用代理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();

  }

  }


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


相关文章内容简介
推荐阅读
  • 08 2019-11
    区分线程IP池与独享IP池

    独享IP池是什么?线程IP池是什么?下面我们从概念以及二者的区别来进行分析,看看是否能够搞懂,帮助大家选择更合适的代理IP。

  • 14 2020-10
    选择不同协议的代理ip

    代理ip到底http协议与socks协议会在使用上有什么差异吗?对于用户来说,要怎么理解?

  • 29 2020-10
    电商与IP代理软件之间的关系

    数十年之前,我们眼中的电商平台或者说我们生活中习惯的电商平台,除了淘宝之外没有别人,但是现在尤其是近几年,随着互联网的发展,基于互联网技术之上的平台越来越多,大家也正在发

  • 13 2019-11
    如何验证代理IP有用?

    购买了代理IP之后,怎么能够验证IP的有效性?今天机灵代理教给大家一个快速验证的方式,下面我们来看看操作思路跟代码步骤。

  • 23 2019-02
    爬虫伪装浏览器和设置代理的方法

    大部分的网站为了避免爬虫的恶意访问,会设置一些反爬虫机制,常见的反爬虫机制主要有:

  • 22 2020-04
    我们为什么需要代理ip

    当我们用爬获取信息时,因为获取的信息较多,所以需要用代理IP来解决IP数量的限制。此外,随着互联网的普及代理IP在我们的生活中十分常见,我们的互联网生活时时需要。代理IP还可以在共

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

大客户经理微信

微信公众号

微信公众号

回到顶部