import com.google.gson.Gson;import other.IPBean;import other.IPList;import other.IPSpider;import util.IPUtils;import java.util.List;/*** @author Asche* @github: https://github.com/asche910* @date 2019年1月19日*/public class Main {public static void main(String[] args){System.out.println("Start: ");IPSpider spider = new IPSpider();List<IPBean> list = spider.crawlHttp(3);System.out.println("爬取数量:" + list.size());Gson gson = new Gson();for (IPBean ipBean : list) {System.out.println(gson.toJson(ipBean));new Thread(new Runnable() {@Overridepublic void run() {boolean valid = IPUtils.isValid(ipBean);if (valid){IPList.add(ipBean);}IPList.increase();}}).start();}while (true){// 判断所有副线程是否完成if (IPList.getCount() == list.size()){System.out.println("有效数量:" + IPList.getSize());break;}}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。