Examples of ReadHTML


Examples of org.encog.parse.tags.read.ReadHTML

  public void testBoth() throws Throwable
  {
    String html="<br/>";
    String htmlName = "br";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getType()==Tag.Type.BEGIN);
    TestCase.assertTrue(tag.getName().equals(htmlName));
    parse.readToTag();
    tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getType()==Tag.Type.END);
    TestCase.assertTrue(tag.getName().equals(htmlName));
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testBothWithAttributes() throws Throwable
  {
    String html="<img src=\"picture.gif\" alt=\"A Picture\"/>";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testComment() throws Throwable
  {
    String html="a<!-- Hello -->b";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()=='a');
    TestCase.assertTrue(parse.read()==0);
    TestCase.assertTrue(parse.read()=='b');
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testScript() throws Throwable
  {
    String html="a<script>12</script>b";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()=='a');
    TestCase.assertTrue(parse.read()==0);
    TestCase.assertTrue(parse.read()=='1');
    TestCase.assertTrue(parse.read()=='2');
    TestCase.assertTrue(parse.read()==0);
    TestCase.assertTrue(parse.read()=='b')
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testScript2() throws Throwable
  {
    String html="a<script>1<2</script>b<br>";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()=='a');
    TestCase.assertTrue(parse.read()==0);
    TestCase.assertTrue(parse.read()=='1');
    TestCase.assertTrue(parse.read()=='<');
    TestCase.assertTrue(parse.read()=='2');
    TestCase.assertTrue(parse.read()==0);
    TestCase.assertTrue(parse.read()=='b')
    TestCase.assertTrue(parse.read()==0);
 
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testToString()
  {
    String html="a<img src=\"picture.gif\" alt=\"A Picture\">b";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    parse.readToTag()
    TestCase.assertTrue(parse.toString().indexOf("A Picture")!=-1);
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testTagToString()
  {
    String html="<br/>";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0)
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testSpecialCharacter() throws Throwable
  {
    String html = "&lt;&gt;&#65;";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()=='<');
    TestCase.assertTrue(parse.read()=='>');
    TestCase.assertTrue(parse.read()=='A');
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

 
  public void testSimpleAttribute() throws Throwable
  {
    String html = "<!DOCTYPE \"test\">";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertEquals(tag.toString(), html);
  }
View Full Code Here

Examples of org.encog.parse.tags.read.ReadHTML

  private Collection<URL> doSearch(final URL url) throws IOException {
    final Collection<URL> result = new ArrayList<URL>();
    // submit the search

    final InputStream is = url.openStream();
    final ReadHTML parse = new ReadHTML(is);
    final StringBuilder buffer = new StringBuilder();
    boolean capture = false;

    // parse the results
    int ch;
    while ((ch = parse.read()) != -1) {
      if (ch == 0) {
        final Tag tag = parse.getTag();
        if (tag.getName().equalsIgnoreCase("url")) {
          buffer.setLength(0);
          capture = true;
        } else if (tag.getName().equalsIgnoreCase("/url")) {
          result.add(new URL(buffer.toString()));
View Full Code Here
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.