-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
82 lines (58 loc) · 2.01 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.LinkedList;
public class Main {
//final static String URL = "file:///F:/Scraping/SS/Dr.%20Olena%20Norris_%20American%20Dental%20Association.html";
final static String URL = "http://technogearup.com/";
public static void main(String[] args) {
FireFoxHandaler fireFoxHandaler = new FireFoxHandaler();
// R&D
//String prox = "186.118.169.85:8080";
//fireFoxHandaler.openBrowser(prox, URL);
//fireFoxHandaler.getDentistData(URL);
ListUrl listUrl = new ListUrl();
LoadUserAgent userAgent = new LoadUserAgent();
LoadProxy listProxy = new LoadProxy();
LinkedList<String> proxies = listProxy.getProxy();
Iterator<String> itProx = proxies.iterator();
int count = 0;
LinkedList<String> lUrl = listUrl.getListUrl();
for (String url : lUrl) {
if(count == 0) {
if(!itProx.hasNext()) break;
fireFoxHandaler.openBrowser(itProx.next(), userAgent.getRandomUserAgent());
}
fireFoxHandaler.getDentistData(url);
count++;
if(count >= 10) {
count = 0;
fireFoxHandaler.closeBrowser();
}
}
if(fireFoxHandaler.isBrowserOpen()) fireFoxHandaler.closeBrowser();
LinkedList<Dentist> infos = fireFoxHandaler.getStoresInfo();
CsvGenerator csvGenerator = new CsvGenerator();
csvGenerator.listtoCsv(infos);
//writeFile("Errors", fireFoxHandaler.errorCountries);
}
public static void writeFile(String name, LinkedList<String> url) {
PrintWriter writer = null;
try {
writer = new PrintWriter(name+".txt", "UTF-8");
writer.println("[");
for(int i=0; i< url.size(); i++) {
writer.println("\"" + url.get(i) + "\", ");
}
writer.println("]");
writer.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}