Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.webRequest.Re.getSingle;

public class Gui extends JFrame {
private JTextField uaText,dataText, targetsPathText;
private JMenuBar fileMenu,helpMenu,proxyMenu;
Expand Down Expand Up @@ -323,6 +325,8 @@ public void actionPerformed(ActionEvent e) {
str2.add("http://"+target+"/"+targetsPathBody);
}
} }
//去重操作
str2=getSingle(str2);
// 多少个目标
total = str2.size();

Expand Down
13 changes: 13 additions & 0 deletions Re.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.webRequest;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -13,4 +15,15 @@ public static String Title (String str){
return ("未获取到title");
}
}
//添加一个URL去重方法
public static ArrayList<String> getSingle(ArrayList<String> list) {
ArrayList<String> tempList = new ArrayList<String>(); //1,创建新集合
Iterator<String> it = list.iterator(); //2,根据传入的集合(老集合)获取迭代器
while(it.hasNext()) { //3,遍历老集合
String obj = it.next(); //记录住每一个元素
if(!tempList.contains(obj)) { //如果新集合中不包含老集合中的元素
tempList.add(obj); //将该元素添加
}
}
return tempList;
}