X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fbasic%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fimpl%2FApp.java;h=90e66dfcca3e6a69f55d04dc088dd22a78347fb2;hb=915f1b7c5af2b85372dc84d008e9a5c49428f0e9;hp=6246453abba66ce5e4cf570cca4aa6b995dc1933;hpb=94445186085ec1ec27bed5a5c07b634da957eb08;p=utils diff --git a/crawler/basic/src/org/wamblee/crawler/impl/App.java b/crawler/basic/src/org/wamblee/crawler/impl/App.java index 6246453a..90e66dfc 100644 --- a/crawler/basic/src/org/wamblee/crawler/impl/App.java +++ b/crawler/basic/src/org/wamblee/crawler/impl/App.java @@ -2,9 +2,7 @@ package org.wamblee.crawler.impl; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.InputStream; -import java.io.PrintStream; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.logging.Log; @@ -36,60 +34,49 @@ import org.wamblee.crawler.PageException; * Entry point for the crawler. */ public final class App { - + /** * Disabled constructor. - * + * */ - private App() { + private App() { // Empty } - - private static final Log LOG = LogFactory.getLog(App.class); - - private static final String LOG_FILE = "crawler.log"; - + /** - * Runs a test program. - * @param aArgs Arguments. First argument is the crawler config file name and second argument is - * the start url. - * @throws Exception In case of problems. + * Runs a test program. + * + * @param aArgs + * Arguments. First argument is the crawler config file name and + * second argument is the start url. + * @throws Exception + * In case of problems. */ public static void main(String[] aArgs) throws Exception { String configFileName = aArgs[0]; String starturl = aArgs[1]; - FileOutputStream fos = new FileOutputStream(new File(LOG_FILE)); - PrintStream os = new PrintStream(fos); - - try { - ConfigurationParser parser = new ConfigurationParser(os); - InputStream configFile = new FileInputStream(new File( - configFileName)); - Configuration config = parser.parse(configFile); - - HttpClient client = new HttpClient(); - // client.getHostConfiguration().setProxy("localhost", 3128); - - Crawler crawler = new CrawlerImpl(client, config); - - System.out.println("Retrieving: " + starturl); - Page page = crawler.getPage(starturl); - showPage(page); - page = page.getAction("channels-favorites").execute(); - recordInterestingShows(page); - showPage(page); - page = page.getAction("Nederland 1").execute(); - showPage(page); - page = page.getAction("right-now").execute(); - showPage(page); - page = page.getAction("Het elfde uur").execute(); - showPage(page); - } finally { - os.flush(); - os.close(); - System.out.println("Output written on '" + LOG_FILE + "'"); - } + ConfigurationParser parser = new ConfigurationParser(); + InputStream configFile = new FileInputStream(new File(configFileName)); + Configuration config = parser.parse(configFile); + + HttpClient client = new HttpClient(); + // client.getHostConfiguration().setProxy("localhost", 3128); + + Crawler crawler = new CrawlerImpl(client, config); + + System.out.println("Retrieving: " + starturl); + Page page = crawler.getPage(starturl); + showPage(page); + page = page.getAction("channels-favorites").execute(); + recordInterestingShows(page); + showPage(page); + page = page.getAction("Nederland 1").execute(); + showPage(page); + page = page.getAction("right-now").execute(); + showPage(page); + page = page.getAction("Het elfde uur").execute(); + showPage(page); } /** @@ -113,7 +100,8 @@ public final class App { } } - private static void examineChannel(String aChannel, Page aPage) throws PageException { + private static void examineChannel(String aChannel, Page aPage) + throws PageException { Action[] programs = aPage.getActions(); for (Action program : programs) { System.out.println(aChannel + " - " + program.getName());