KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > JSpider


1 package net.javacoding.jspider;
2
3
4 import net.javacoding.jspider.core.*;
5 import net.javacoding.jspider.core.impl.CLI;
6 import net.javacoding.jspider.core.util.config.ConfigurationFactory;
7
8 import java.net.URL JavaDoc;
9
10 /**
11  * Main startup class.
12  *
13  * $Id: JSpider.java,v 1.27 2003/04/10 16:19:03 vanrogu Exp $
14  *
15  * @author Günther Van Roey
16  * @todo support commandline input for proxy password
17  * @todo implement Swing-based monitor UI ( threading, progress, ...)
18  */

19 public class JSpider {
20
21     protected Spider spider;
22     protected SpiderContext context;
23
24     public JSpider ( URL JavaDoc baseURL ) throws Exception JavaDoc {
25         SpiderNest nest = new SpiderNest();
26         context = SpiderContextFactory.createContext(baseURL);
27         spider = nest.breedSpider(context);
28     }
29
30     public void start ( ) throws Exception JavaDoc {
31         spider.crawl(context);
32     }
33
34     public SpiderContext getContext() {
35         return context;
36     }
37
38     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
39
40         CLI.printSignature();
41
42         if (args.length != 1 && args.length != 2 ) {
43             System.out.println("Usage: JSpider baseURL [config]");
44             return;
45         }
46
47         if (args.length > 1) {
48             ConfigurationFactory.getConfiguration(args[1]);
49         } else {
50             ConfigurationFactory.getConfiguration();
51         }
52
53         URL JavaDoc baseURL = new URL JavaDoc(args[0]);
54
55         JSpider jspider = new JSpider ( baseURL );
56         jspider.start ( );
57     }
58
59 }
Popular Tags