Package org.vietspider.token.attribute

Examples of org.vietspider.token.attribute.Attributes


      if(node.isNode(Name.FORM)) {
//        System.out.println("== > thay "+ node + " : "+ node.isOpen()  );
        if(node.getType() == TypeToken.TAG) {
          if(form != null) forms.add(form);
          form = new Form();
          Attributes attributes = node.getAttributes();
          Attribute attribute = attributes.get(NAME_ATTR);
          if(attribute != null) form.setName(attribute.getValue());
          attribute = attributes.get("method");
          if(attribute != null) form.setMethod(attribute.getValue());
          attribute = attributes.get(ACTION);
          if(attribute != null) form.setAction(attribute.getValue());
        } else {
          if(form != null) forms.add(form);
          form = null;
        }
      } else if(node.isNode(Name.INPUT)
          || node.isNode(Name.TEXTAREA)
          || node.isNode(Name.SELECT)) {       
        if(form == null) continue;
       
        Attributes attributes = node.getAttributes();
        Attribute attribute = attributes.get(NAME_ATTR);
        if(attribute == null) attribute = attributes.get(ID_ATTR);;
        if(attribute == null) continue;
        String name  = attribute.getValue();
        if(name == null || name.trim().isEmpty()) continue;
       
        attribute = attributes.get(TYPE_ATTR);
        String type = null;
        if(attribute != null) type = attribute.getValue();
        if(type == null) type = "text";
        type = type.trim();
       
        if(type.equalsIgnoreCase("submit")) {
          if(name.toLowerCase().indexOf("cancel") > -1
              || name.toLowerCase().indexOf("reset") > -1
              || name.toLowerCase().indexOf("clear") > -1) continue;
        }
       
        if("radio".equalsIgnoreCase(type)
            || "checkbox".equalsIgnoreCase(type)) {
          attribute = attributes.get("checked");
          if(attribute == null) continue;
        }
       
        attribute = attributes.get(VALUE);
        String value = null;
        if(attribute != null) value = attribute.getValue();
        if(value == null) value = "";
        value  = value.trim();
       
View Full Code Here


    NodeIterator iterator = root.iterator();
  
    while(iterator.hasNext()) {
      HTMLNode node = iterator.next();
      if(!node.isNode(Name.DIV)) continue;
      Attributes attributes = node.getAttributes();
      Attribute attribute = attributes.get("id");
      if(attribute == null) continue;
      String value = attribute.getValue();
      if(value == null) continue;
     
      if("posts".equalsIgnoreCase(value)) {
View Full Code Here

  private HTMLNode searchUserNode(HTMLNode root) {
    NodeIterator iterator = root.iterator();
    while(iterator.hasNext()) {
      HTMLNode node = iterator.next();
      if(!node.isNode(Name.A)) continue;
      Attributes attributes = node.getAttributes();
      Attribute attribute = attributes.get("class");
      if(attribute == null) continue;
      String value = attribute.getValue();
      if(value == null) continue;
      value = value.toLowerCase();
      if(value.indexOf("bigusername") > -1) return node;
View Full Code Here

  private HTMLNode searchContentNode(HTMLNode root, String clazz) {
    NodeIterator iterator = root.iterator();
    while(iterator.hasNext()) {
      HTMLNode node = iterator.next();
      if(!node.isNode(Name.DIV)) continue;
      Attributes attributes = node.getAttributes();
      Attribute attribute = attributes.get("id");
      if(attribute == null) continue;
      String value = attribute.getValue();
      if(value == null) continue;
      value = value.toLowerCase();
      if(value.indexOf(clazz) > -1) {//"post_message"
View Full Code Here

  private boolean isPageList(HTMLNode node) {
    NodeIterator iterator = node.iterator();
    while(iterator.hasNext()) {
      HTMLNode n = iterator.next();
      if(!n.isNode(Name.A)) continue;
      Attributes attributes = n.getAttributes();
      Attribute attribute = attributes.get("href");
      if(attribute == null) continue;
      String value = attribute.getValue();
      if(value == null) continue;
      if(value.indexOf("page=") > -1) return true;
    }
View Full Code Here

    for(;i < tokens.size(); i++) {
      NodeImpl node = tokens.get(i);
     
      if(node.isNode(Name.FORM)) {
        if(formName == null) break;       
        Attributes attrs = node.getAttributes();
        String name = getAttribute(attrs, NAME_ATTR);
        if(formName.equalsIgnoreCase(name)) break;
      }
    }

    HTMLNode form = null;
    List<HTMLNode> inputs = new ArrayList<HTMLNode>();

    for(; i < tokens.size(); i++) {
      NodeImpl node = tokens.get(i);
      if(node.isNode(Name.FORM)) {
        if(node.isOpen()) {
          form = node;
        } else {
          break;
        }
      } else if(node.isNode(Name.INPUT)
          || node.isNode(Name.TEXTAREA)
          || node.isNode(Name.SELECT)) {       
        inputs.add(node);
      }
    }
   
    if(form == null || inputs.size() < 1) {
      message = "Error: form not found";
      return ERROR;
    }
   
    String address = getAttribute(form, ACTION);
    if(address == null) {
      message = "Error: post address not found!";
      return ERROR;
    }
   
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    for(i = 0 ; i < inputs.size(); i++) {
      Attributes attrs = inputs.get(i).getAttributes();
      String name = getAttribute(attrs, NAME_ATTR);
      if(name == null) getAttribute(attrs, ID_ATTR);
      if(name == null) continue;
      String type = getAttribute(attrs, TYPE_ATTR);
      if(type == null) type = "text";
View Full Code Here

//    }
    params.add(newPair);
  }

  public String getAttribute(HTMLNode node, String name) {
    Attributes attrs = node.getAttributes();
    int idx = attrs.indexOf(name);
    if(idx < 0) return null;
    return attrs.get(idx).getValue();
  }
View Full Code Here

 
  private boolean equalsFormat(HTMLNode node1, HTMLNode node2) {
    Name name1 = node1.getName();
    Name name2 = node2.getName();
    if(name1 != name2) return false;
    Attributes attributes1 = node1.getAttributes();
    Attributes attributes2 = node2.getAttributes();
    if(attributes1.size() != attributes2.size()) return false;
    for(int i = 0;  i < attributes1.size(); i++) {
      Attribute attribute1 = attributes1.get(i);
      Attribute attribute2 = attributes2.get(i);
      if(attribute1 == null && attribute2 != nullreturn false;
      if(attribute1 != null && attribute2 == nullreturn false;
      if(attribute1 != null && attribute2 != null
          && !attribute1.getName().equalsIgnoreCase(attribute2.getName()))  return false;
    }
View Full Code Here

* Feb 9, 2009 
*/
public class RenderNodeUtils {
 
  public static int getIntAttrValue(HTMLNode node, String name) {
    Attributes attributes = node.getAttributes();
    return getIntAttrValue(attributes, name);
  }
View Full Code Here

        if(attrs == null || attrs.length < 1) {
//        System.out.println(" da xay ra roi ");
          htmlValues.add(htmlChildren.get(i));
        } else {
//          System.out.println(" xay ra ");
          Attributes nodeAttributes = htmlChildren.get(i).getAttributes();
          if(matcher.contains(nodeAttributes, attrs)) htmlValues.add(htmlChildren.get(i));
        }
      }
      counter++;
   
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.