1 27 package org.htmlparser.tests; 28 29 import org.htmlparser.Parser; 30 import org.htmlparser.visitors.TagFindingVisitor; 31 32 public class BadTagIdentifier { 33 34 public BadTagIdentifier() { 35 super(); 36 } 37 38 public static void main(String [] args) 39 throws Exception { 40 BadTagIdentifier badTags = 41 new BadTagIdentifier(); 42 badTags.identify("http://www.amazon.com"); 43 } 44 45 private void identify(String url) 46 throws Exception { 47 String [] tagsBeingChecked = 48 {"TABLE","DIV","SPAN"}; 49 50 Parser parser = 51 new Parser(url); 52 TagFindingVisitor tagFinder = 53 new TagFindingVisitor(tagsBeingChecked, true); 54 parser.visitAllNodesWith(tagFinder); 55 for (int i=0;i<tagsBeingChecked.length;i++) { 56 System.out.println( 57 "Number of "+tagsBeingChecked[i]+" begin tags = "+ 58 tagFinder.getTagCount(i)); 59 System.out.println( 60 "Number of "+tagsBeingChecked[i]+" end tags = "+ 61 tagFinder.getEndTagCount(i)); 62 } 63 64 } 65 } 66 | Popular Tags |