Package org.vietspider.token.attribute

Examples of org.vietspider.token.attribute.Attribute


    return false;
  }
 
  private boolean hasOnclick(HTMLNode node) {
    Attributes attributes = node.getAttributes();
    Attribute attribute = attributes.get("onclick");
    if(attribute == null) return false;
    String value  = attribute.getValue();
    if(value == null || (value = value.trim()).isEmpty()) return false;
    return true;
  }
View Full Code Here


  }
 
  private boolean compareAttributes(Attributes attributes1, Attributes attributes2) {
    if(attributes1.size() != attributes2.size()) return false;
    for(int i = 0; i < attributes1.size(); i++) {
      Attribute attr1 = attributes1.get(i);
      Attribute attr2 = attributes2.get(i);
      String name = attr1.getName();
      if(isIgnoreAttribute(name)) continue;
      if(!name.equalsIgnoreCase(attr2.getName()))  return false;
      if(isIgnoreAttributeValue(name)) continue;
      if(!attr1.getValue().equalsIgnoreCase(attr2.getValue()))  return false;
    }
    return true;
  }
View Full Code Here

    return false;
  }
 
  private String getLinkAttribute(HTMLNode node) {
    Attributes attributes = node.getAttributes();
    Attribute attribute = attributes.get("href");
    if(attribute != null) {
      String link = attribute.getValue();
      if(link != null && !(link = link.trim()).isEmpty()) {
        if(link.charAt(0) == '#') return null;
        return link;
      }
    }
    attribute = attributes.get("onclick");
    if(attribute == null) return  null;
    String link = attribute.getValue();
    if(link == null
        || (link = link.trim()).isEmpty()
        || link.charAt(0) == '#') return null;
    return link;
  }
View Full Code Here

    NodeIterator iterator = node.iterator();
    while(iterator.hasNext()) {
      HTMLNode n = iterator.next();
      if (n.isNode(Name.A)) {
        Attributes attrs = n.getAttributes();
        Attribute attr = attrs.get("name");
        if (attr != null) anchors.add(n);
      }
    }
  }
View Full Code Here

    searchAnchors(root, anchors);

    int i = 0;
    for (; i < anchors.size(); i++) {
      Attributes attrs = anchors.get(i).getAttributes();
      Attribute attr = attrs.get("name");
      if (attr.getValue().equals(name)) break;
    }

    if (i < anchors.size() - 1) {
      return processNextNode(root, anchors, i);
    } else if (i > 0) {
View Full Code Here

      HTMLNode n = iterator.next();
     
      handleNode(n);
     
      if(!n.isTag()) continue;
      Attribute attr = getAttribute(n);
      if(attr == null) continue;
      String attrValue = attr.getValue();
      if(attrValue == null) continue;
      if (verifier == null || verifier.verify(attrValue)) list.add(attrValue);
    }
  }
View Full Code Here

  }
 
  public String getAttributeValue(HTMLNode node) {  
    NodeIterator iterator = node.iterator();
    while(iterator.hasNext()) {
      Attribute attr = getAttribute(iterator.next());   
      if(attr != null
        && (verifier == null || verifier.verify(attr.getValue()))) return attr.getValue()
    }
    return null;
  }
View Full Code Here

    }
  }
 
  private void searchOnclick(HTMLNode n) {
    Attributes attributes = n.getAttributes();
    Attribute attribute = attributes.get("onclick");
    if(attribute == null || attribute.getValue() == null) return ;
    String jsFunction = attribute.getValue();
    String [] params = JsUtils.getParams(jsFunction);
    for(int i = 0 ; i < params.length; i++) {
      list.add(params[i]);
    }
  }
View Full Code Here

    }
  }
 
  private void searchMetaRefresh(HTMLNode n) {
    Attributes attributes = n.getAttributes();
    Attribute attribute = attributes.get("http-equiv");
    if(attribute == null || attribute.getValue() == null) return ;
   
    if(!"refresh".equalsIgnoreCase(attribute.getValue().trim())) return ;
   
    attribute = attributes.get("content");
    if(attribute == null) return ;
    String link = attribute.getValue();
   
    if(link == null) return;
    link = cleanLink(link.trim());
    if(link == null) return ;
    list.add(link);
View Full Code Here

 
  private void searchBodyLocation(HTMLNode n) {
//    System.out.println(value);
    Attributes attributes = n.getAttributes();
//    System.out.println(attributes.length);
    Attribute attribute = attributes.get("onload");
    if(attribute == null || attribute.getValue() == null) return ;
    String [] params = JsUtils.getParams(attribute.getValue());
    for(String param : params) {
      System.out.println(param);
    }
  }
View Full Code Here

TOP

Related Classes of org.vietspider.token.attribute.Attribute

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.