Package org.vietspider.token.attribute

Examples of org.vietspider.token.attribute.Attributes


    List<HTMLNode> anchors = new ArrayList<HTMLNode>();
    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);
View Full Code Here


    this.attrName = attrName;
  }
 
  public Attribute getAttribute(HTMLNode node){
    if(node.isNode(nodeName) || (nodeName.length() == 1 && nodeName.charAt(0) == '*')){
      Attributes attrs = node.getAttributes();  
      int idx = attrs.indexOf(attrName);
      if(idx > -1) return attrs.get(idx);
    }
    return null;
  }
View Full Code Here

    Set<String> keys = map.keySet();
    Iterator<String> iter = keys.iterator();
    while(iter.hasNext()){
      String key = iter.next();
      if(node.isNode(key) || (key.length() == 1 && key.charAt(0) == '*')){
        Attributes attrs = node.getAttributes();  
        int idx = attrs.indexOf(map.get(key));
        if(idx > -1) return attrs.get(idx);
      }
    }
    return null;
  }
View Full Code Here

      break;
    }
  }
 
  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

      list.add(params[i]);
    }
  }
 
  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());
View Full Code Here

    list.add(value);
  }
 
  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

    Set<String> keys = map.keySet();
    Iterator<String> iter = keys.iterator();
    while(iter.hasNext()){
      String key = iter.next();
      if(node.isNode(key) || (key.length() == 1 && key.charAt(0) == '*')){
        Attributes attrs = node.getAttributes()
        Attribute attr = attrs.get(map.get(key));
        if(attr == nullcontinue;
        String value = attr.getValue();
        if(value == null) continue;
        if(verifier != null && !verifier.verify(value)) continue;
//        System.out.println("truoc "+value);
        value  = urlCreator.createURL(home, value);
//        System.out.println("sau "+value);
        attr.setValue(value);     
        attrs.set(attr);
      }
    } 
  }
View Full Code Here

 
  private void createFullSingleLink(HTMLNode node,
      String nodeName, String attrName, URL home, ValueVerifier verifier)   {
    Attribute attr = null;
    if(node.isNode(nodeName) || (nodeName.length() == 1 && nodeName.charAt(0) == '*')) {
      Attributes attrs = node.getAttributes()
      int idx = attrs.indexOf(attrName);
      if(idx < 0return;
      attr = attrs.get(idx);
      String value = attr.getValue();
      if(verifier != null && !verifier.verify(value)) return;
      value  = urlCreator.createURL(home, value);     
      attr.setValue(value);     
      attrs.set(attr);
    }
  }
View Full Code Here

    NodeIterator iterator = root.iterator();
    while(iterator.hasNext()) {
      HTMLNode n = iterator.next();
      if(!n.isNode(Name.META)) continue;
      if(n.isNode(Name.BODY)) break;
      Attributes attributes = n.getAttributes();
      Attribute attribute = attributes.get("http-equiv");
      if(attribute == null || attribute.getValue() == null) continue;

      if(!"content-type".equalsIgnoreCase(attribute.getValue().trim())) continue ;

      attribute = attributes.get("content");
      if(attribute == null) continue;
      String link = attribute.getValue();
      if(link == null) continue;
      int index = link.toLowerCase().indexOf("=");
View Full Code Here

    Set<String> keys = map.keySet();
    Iterator<String> iter = keys.iterator();
    while(iter.hasNext()){
      String key = iter.next();
      if(node.isNode(key) || (key.length() == 1 && key.charAt(0) == '*')){
        Attributes attrs = node.getAttributes()
        Attribute attr = attrs.get("src");
        if(attr == nullcontinue;
        String value = attr.getValue();
        if(verifier != null && !verifier.verify(value)) continue;
        value  = urlCreator.createURL(home, value);
        attr.setValue(value);     
        attrs.set(attr);
      }
    } 
  }
View Full Code Here

TOP

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

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.