Package org.htmlparser

Examples of org.htmlparser.NodeFilter


    Parser parser = new Parser();

    String html = Common.getInputHtmlGBK(urlStr);
    parser.setInputHTML(html);
    String filerStr = "li";
    NodeFilter filter = new TagNameFilter(filerStr);
    // 取得页面内容中标签为"dl"
    NodeList nodeList = parser.extractAllNodesThatMatch(filter);

    Tag tag = (Tag) nodeList.elementAt(0);
View Full Code Here


   */
  public static <T extends TagNode> List<T> parseTags(String html, final Class<T> tagType, final String attrbuteName, final String attrbutValue) {
    try {
      Parser parser = new Parser();
      parser.setInputHTML(html);
      NodeList list = parser.parse(new NodeFilter() {

        public boolean accept(Node node) {
          if (node.getClass() == tagType) {
            T tagNode = (T) node;
            if (attrbuteName == null) {
View Full Code Here

    public static final String SWIMLANE_SEP = "__#Swimlane_Separator#__";

    protected static Node getElementById(Parser parser, String id) {
        parser.reset();
        NodeFilter filter = new CssSelectorNodeFilter("#" + id);
        try {
            NodeList list = parser.extractAllNodesThatMatch(filter);
            if (list.size() > 0) {
                return list.elementAt(0);
            }
View Full Code Here

 
  public static final String SWIMLANE_SEP = "__#Swimlane_Separator#__";
 
  protected Node getElementById(Parser parser, String id) {
    parser.reset();
    NodeFilter filter = new CssSelectorNodeFilter("#" + id);
    try {
      NodeList list = parser.extractAllNodesThatMatch(filter);
      if (list.size() > 0) {
        return list.elementAt(0);
      }
View Full Code Here

      if (categories == null) {
       
      try {
        parser.setURL(BROWSE_CATEGORIES_URL);
 
        NodeFilter categoryFilter = new AndFilter(
            new HasAncestorFilter(new HasAttributeFilter("id", "genres")),
            new NodeClassFilter(LinkTag.class)
        );
 
        NodeList categoryNodes = parser.extractAllNodesThatMatch(categoryFilter);
View Full Code Here

      get.releaseConnection();
      */
     
      parser.setURL(QUEUE_URL);

      NodeFilter queueFilter = new OrFilter(
        new CssClassFilter("dvd-out"),
        new HasAttributeFilter("id", "dvd-queue")
      );

      NodeList queueNodes = parser.extractAllNodesThatMatch(queueFilter);
View Full Code Here

      throw io;
    }
  }
 
  private void parseShippedList(Node queue, List<MovieItem> items) {
    NodeFilter discFilter = new CssClassFilter("or");
    NodeCollector infoCollector = new NodeCollector(new NodeFilter[] {
        new AndFilter(new NodeClassFilter(LinkTag.class),
            new HasParentFilter(new CssClassFilter("qt"))),
        new AndFilter(new NodeClassFilter(ImageTag.class),
            new CssClassFilter("star")),
View Full Code Here

      items.add(movie);
    }
  }
 
  private void parseMovieQueue(Node queue, List<MovieItem> items) {
    NodeFilter discFilter = new CssClassFilter("bd");
    NodeCollector infoCollector = new NodeCollector(new NodeFilter[] {
        new AndFilter(new NodeClassFilter(LinkTag.class),
            new HasParentFilter(new CssClassFilter("stc"))),
           
        new AndFilter(new NodeClassFilter(ImageTag.class),
View Full Code Here

              log.info("Browsing... page=" + page + ",category=" + category);
          }
     
      parser.setURL(BROWSE_CATEGORY_URL + category.getId() + "&pageNum=" + page);
 
      NodeFilter discFilter = new AndFilter(
          new NodeClassFilter(TableRow.class),
          new HasChildFilter(new HasChildFilter(new CssClassFilter("list-title")))
      );
     
 
View Full Code Here

          }
     
          String url = MessageFormat.format(SEARCH_URL, URLEncoder.encode(query, "UTF-8"), start);
      parser.setURL(url);

      NodeFilter discFilter = new AndFilter(
          new NodeClassFilter(TableRow.class),
          new HasChildFilter(new HasChildFilter(new CssClassFilter("searchDisplay")))
      );
     
      NodeCollector searchCollector = new NodeCollector(new NodeFilter[] {
View Full Code Here

TOP

Related Classes of org.htmlparser.NodeFilter

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.