01: package net.javacoding.jspider;
02:
03: import net.javacoding.jspider.core.*;
04: import net.javacoding.jspider.core.impl.CLI;
05: import net.javacoding.jspider.core.util.config.ConfigurationFactory;
06:
07: import java.net.URL;
08:
09: /**
10: * Main startup class.
11: *
12: * $Id: JSpider.java,v 1.27 2003/04/10 16:19:03 vanrogu Exp $
13: *
14: * @author Günther Van Roey
15: * @todo support commandline input for proxy password
16: * @todo implement Swing-based monitor UI ( threading, progress, ...)
17: */
18: public class JSpider {
19:
20: protected Spider spider;
21: protected SpiderContext context;
22:
23: public JSpider(URL baseURL) throws Exception {
24: SpiderNest nest = new SpiderNest();
25: context = SpiderContextFactory.createContext(baseURL);
26: spider = nest.breedSpider(context);
27: }
28:
29: public void start() throws Exception {
30: spider.crawl(context);
31: }
32:
33: public SpiderContext getContext() {
34: return context;
35: }
36:
37: public static void main(String[] args) throws Exception {
38:
39: CLI.printSignature();
40:
41: if (args.length != 1 && args.length != 2) {
42: System.out.println("Usage: JSpider baseURL [config]");
43: return;
44: }
45:
46: if (args.length > 1) {
47: ConfigurationFactory.getConfiguration(args[1]);
48: } else {
49: ConfigurationFactory.getConfiguration();
50: }
51:
52: URL baseURL = new URL(args[0]);
53:
54: JSpider jspider = new JSpider(baseURL);
55: jspider.start();
56: }
57:
58: }
|