KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > matuschek > examples > LogURL


1 package net.matuschek.examples;
2
3 import java.io.FileWriter JavaDoc;
4 import java.net.URL JavaDoc;
5 import net.matuschek.http.URLLogger;
6 import net.matuschek.spider.WebRobot;
7 /*********************************************
8     Copyright (c) 2001 by Daniel Matuschek
9 *********************************************/

10
11
12
13 /**
14  * This example program downloads a web page. It does not
15  * store the documents but only logs the visited URLs.
16  *
17  * @author Daniel Matuschek
18  * @version $Revision: 1.2 $
19  */

20 public class LogURL {
21
22   public static void main(String JavaDoc[] args)
23     throws Exception JavaDoc
24   {
25     System.out.println("URLs will be logged to urls.txt\n\n");
26
27     WebRobot robby = new WebRobot();
28     robby.setStartURL(new URL JavaDoc("http://www.matuschek.net"));
29     robby.setMaxDepth(1);
30     robby.setSleepTime(0);
31
32     FileWriter JavaDoc logfile = new FileWriter JavaDoc("urls.txt");
33     URLLogger log = new URLLogger(logfile);
34     robby.setDocManager(log);
35
36     robby.run();
37     logfile.close();
38   }
39 }
40   
41
Popular Tags