Package barrysoft.web

Examples of barrysoft.web.WebDownloader


    Parser p = new Parser("Time Parser");
    p.addRule(new ParserRule(timeRule));
   
    try {
     
      p.parseData(new WebDownloader(timeURL));
     
      String[][] results = p.getRule(0).getResults();
     
      checkResults(results, 1, new int[] {1});
View Full Code Here


   
    p.addRule(pr);
   
    try {
     
      WebDownloader wd = new WebDownloader("http://www.italiansubs.net/index.php");
      wd.addFormElement("option", "com_remository");
     
      p.parseData(wd);

      String[][] results = p.getRule(0).getResults();
     
View Full Code Here

    for (String rule : multipleRules)
      p.addRule(new ParserRule(rule));
   
    try {
     
      WebDownloader wd = new WebDownloader("http://www.italiansubs.net/index.php");
      wd.addFormElement("option", "com_remository");
      wd.addFormElement("func", "fileinfo");
      wd.addFormElement("id", "2126");
     
      p.parseData(wd);

      for (int i=0; i < multipleRules.length; i++) {
        String[][] results = p.getRule(i).getResults();
View Full Code Here

   
    try {
     
      pr.getParam("tag").addValue("Dimensioni del file: ");
     
      WebDownloader wd = new WebDownloader("http://www.italiansubs.net/index.php");
      wd.addFormElement("option", "com_remository");
      wd.addFormElement("func", "fileinfo");
      wd.addFormElement("id", "2126");
     
      p.parseData(wd);
     
      String[][] results = p.getRule(0).getResults();
      checkResults(results, 1, new int[] {1});
View Full Code Here

    rule.setGroupName("Language", 0);
    rule.setGroupName("Link", 1);
   
    p.addRule(rule);
   
    WebDownloader dl = new WebDownloader();
    try {
      dl.setUrl("http://www.tvsubtitles.net/episode-3079.html");
    } catch (MalformedURLException e) {
      fail(e.getMessage());
    }
   
    try {
View Full Code Here

public class WebDownloaderTest {

  @Test
  public void testDownload() {
   
    WebDownloader downloader = new WebDownloader();
   
    try {
      downloader.setUrl("http://it.wikipedia.org/wiki/CSS_(informatica)");
      String source = new String(downloader.download());
     
      assertTrue(source.length() > 0);
    } catch (IOException e) {
      fail(e.getMessage());
    }
View Full Code Here

  }
 
  @Test
  public void testDownloadToFile() {
   
    WebDownloader downloader = new WebDownloader();
   
    try {
      downloader.setUrl("http://it.wikipedia.org/wiki/CSS_(informatica)");
      downloader.download(new File("test_page.html"));
     
      File f = new File("test_page.html");
     
      if (!f.exists())
        assertTrue("File doesn't exists", false);
View Full Code Here

   
  }
 
  @Test
  public void testSaving() {
    WebDownloader downloader = new WebDownloader();
   
    try {
      downloader.setUrl("http://www.google.com");
      downloader.setMethod(WebDownloader.METHOD_POST);
      downloader.setBufferSize(512);
      downloader.setFollowsRedirects(false);
      downloader.setCacheEnabled(true);
      downloader.setUserAgent(WebDownloader.CHROME_UA);
      downloader.addFormElement("q", "Your mother");
      downloader.addFormElement("name", "die!");
     
      String source = downloader.getXML(0);
     
      System.out.println(source);
     
      downloader = new WebDownloader();
     
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
     
      DocumentBuilder db = null;
      try {
        db = dbf.newDocumentBuilder();
      } catch (ParserConfigurationException e1) {
        fail(e1.getMessage());
      }
     
      Document doc = null;
      try {
        doc = db.parse(new InputSource(new StringReader(source)));
      } catch (SAXException e) {
        fail(e.getMessage());
      } catch (IOException e) {
        fail(e.getMessage());
      }
     
      downloader.loadFromXML(doc.getFirstChild());
     
      assertEquals(source, downloader.getXML(0));
     
    } catch (MalformedURLException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

  }

  @Test
  public void testRedirect() {
   
    WebDownloader downloader = new WebDownloader();
   
    try {
      downloader.setUrl("http://www.barrysoft.it/SiteV3/Products.asp?ID=10");
      String source = new String(downloader.download());
     
      if (source.contains("Marathon Infinity"))
        assertTrue(true);
      else
        fail("Can't find the string:\n\n"+source);
View Full Code Here

  public final String querySite = "http://www.timeanddate.com/worldclock/city.html?bla=1&bla2=3";
 
  @Test
  public void testQuery() {
   
    WebDownloader downloader = new WebDownloader();
    downloader.addFormElement("n", "215");
   
    try {
      downloader.setUrl(querySite);
      String source = new String(downloader.download());
     
      if (source.contains("Rome, Italy"))
        assertTrue(true);
      else
        fail("Can't find the string:\n\n"+source);
View Full Code Here

TOP

Related Classes of barrysoft.web.WebDownloader

Copyright © 2018 www.massapicom. 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.