Package com.crawljax.plugins.savecrawlsession.example

Source Code of com.crawljax.plugins.savecrawlsession.example.SaveCrawlSessionExample

package com.crawljax.plugins.savecrawlsession.example;

import org.apache.commons.configuration.ConfigurationException;

import com.crawljax.browser.EmbeddedBrowser.BrowserType;
import com.crawljax.core.CrawljaxController;
import com.crawljax.core.CrawljaxException;
import com.crawljax.core.configuration.CrawlSpecification;
import com.crawljax.core.configuration.CrawljaxConfiguration;
import com.crawljax.plugins.savecrawlsession.SaveCrawlSession;
import com.crawljax.plugins.savecrawlsession.Utils;

/**
* Crawls a default URL and produces a session.xml file.
*/
public class SaveCrawlSessionExample {

  /**
   * @param args
   *            args are ignored
   */
  public static void main(String[] args) {

    CrawlSpecification spec = new CrawlSpecification(Utils.URL);
    spec.setMaximumStates(5);
    spec.clickDefaultElements();

    CrawljaxConfiguration config = new CrawljaxConfiguration();
    config.setBrowser(BrowserType.firefox);
    config.setCrawlSpecification(spec);

    SaveCrawlSession saveCrawlSessionPlugin = new SaveCrawlSession(Utils.SESSION_XML);
    saveCrawlSessionPlugin.setOutputFolder(Utils.OUTPUTFOLDER);
    config.addPlugin(saveCrawlSessionPlugin);

    try {
      CrawljaxController controller = new CrawljaxController(config);
      controller.run();
    } catch (ConfigurationException e) {
      e.printStackTrace();
      System.exit(1);
    } catch (CrawljaxException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }

}
TOP

Related Classes of com.crawljax.plugins.savecrawlsession.example.SaveCrawlSessionExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.