I want to ask a question. I have to download several data from a website but some data failed when downloading. So I do the search on that website and if i want to download it successfully, I have to select all the check box. So actually I download it automatically with Java, how can I select all the check box before download?
List<Path> files = Component.makePathList(Paths.get(url));
List<Thread> threads = new ArrayList<Thread>();
List<String> alinks = new ArrayList<String>();
try {
for (Path file : files) {
filePos = file.toFile().getName();
List<String> links = Files.readAllLines(file);
alinks.addAll(links);
for (int i = 0; i < links.size(); i++) {
String fileName = Component.matches("[0-9]{3,}", links.get(i)).concat(".html");
String destination = desHTMLFile.concat("\\"+fileName);
WipoDownloadHTMLHelper helper = new WipoDownloadHTMLHelper(destination, links.get(i));
Thread a = new Thread(helper);
a.start();
linePos = i;
threads.add(a);
if (threads.size() % 100 == 0) {
System.out.println(threads.size() % 100);
threads = cleanThreads(threads);
Thread.sleep(10000);
System.gc();
continue;
}
Thread.sleep(5000);
}
threads = cleanThreads(threads);
System.gc();
}
System.out.println("FILES NAME is " + this.filePos);
System.out.println("Lines is " + this.linePos);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
System.err.println("FILES NAME is " + this.filePos);
System.err.println("Lines is " + this.linePos);
}
Aucun commentaire:
Enregistrer un commentaire