-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
66 lines (46 loc) · 1.35 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
import java.io.PrintWriter;
import processing.core.*;
public class Main extends PApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
String[] urls = new String[100];
Crawler crawler;
PrintWriter output;
public void setup() {
size(200,200);
crawler = new Crawler();
output = createWriter("positions.txt");
// Initialize all "stripes"
for (int i = 1; i < 98; i++)
{
//stripes[i] = new Stripe(this);
String url = "http://thefreshmilk.com/page/" + i;
urls[i] = url;
println(url);
crawler.addURL(url);
while (!crawler.queueEmpty())
{
crawler.crawl();
}//endwhile
}//endfor
//convert the arraylist into an array and then save to a file.
String[] authors = new String[crawler.getAuthors().size()];
String[] dates = new String[crawler.getDates().size()];
for (int i=0; i < crawler.getAuthors().size(); i++)
{
// Write the coordinate to a file with a
// "\t" (TAB character) between each entry
dates[i] = (String)crawler.getDates().get(i);
authors[i] = (String)crawler.getAuthors().get(i);
output.println(dates[i] + "\t" + authors[i]);
}//endfor
//saveStrings("authors.txt", authors);
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}//endsetup
public void draw() {
}
}