Package org.vietspider.token.attribute

Examples of org.vietspider.token.attribute.Attribute


    for(int i = 0; i < tokens.size(); i++) {
      NodeImpl token = tokens.get(i);
      if(token.getType() != TypeToken.TAG || !token.isNode(Name.A)) continue;
      Attributes attributes = token.getAttributes();
      Attribute attribute = attributes.get("href");
      if(attribute == null) continue;
      String link  = attribute.getValue();
      if(link == null || link.trim().length() < 1) continue;
      link  = urlUtils.createURL(parent, link);
      String subName = "";
      try {
        URL subUrl = new URL(link);
        String temp = subUrl.getPath();
        if(temp != null) subName += temp;
        temp = subUrl.getQuery();
        if(temp != null) subName += "_"+temp;
        subName = toName(subName);
      }catch (Exception e) {
      }
      if(subName == null || subName.trim().length() < 1) subName = toName(link);
      try{
        crawl(new URL(address), link, subName, level+1, depth);
      }catch (Exception e) {
        System.err.println(e);
      }
      attribute.setValue(subName+".html");
      attributes.set(attribute);
    }


    StringBuilder contentBuilder = new StringBuilder();
View Full Code Here


     
      if(current != null && current instanceof Collection) {
        collection = (Collection) current;
      } else if(type.isInterface())  {
        Attributes attributes = AttributeParser.parse(node);
        Attribute attr = attributes.get("type");
        if(attr != null) {
          String typeName = attr.getValue();
          Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(typeName);
          collection = (Collection) clazz.newInstance();
        } else {
          collection = new ArrayList<Object>();
        }
View Full Code Here

   
    if(current != null && current instanceof Map<?,?>) {
      map = (Map<Object, Object>) current;
    } else if(type.isInterface())  {
      Attributes attributes = AttributeParser.parse(node);
      Attribute attr = attributes.get("type");
      if(attr != null) {
        String typeName = attr.getValue();
        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(typeName);
        map =  (Map<Object, Object>) clazz.newInstance();
      } else {
        map = new Hashtable<Object, Object>();
      }
View Full Code Here

      if(ele.getName().equals(name)){
        ele.setValue(value);
        return ;
      }
    }
    Attribute attr = new Attribute(name, value);
    attrs.add(attr);
  }
View Full Code Here

      if(child.isNode(LINK) && child.getChildren().size() > 0) {
        item.addLink(new MetaLink(child.getChild(0).getTextValue()));
      } else if(child.isNode(ENCLOSURE)) {
        Attributes attributes = AttributeParser.parse(child);
        MetaLink metaLink  = new MetaLink();
        Attribute attribute = attributes.get(URL);
        if(attribute != null) metaLink.setHref(attribute.getValue());
        attribute = attributes.get(TYPE);
        if(attribute != null) metaLink.setType(attribute.getValue());
        item.addLink(metaLink);
      }
    }
  }
View Full Code Here

    for(XMLNode child : children) {
      if(!child.isNode(LINK)) continue;
      MetaLink metaLink = toBean.toBean(MetaLink.class, child);
      if(metaLink.getHref() == null || metaLink.getHref().trim().isEmpty()) {
        Attributes attributes = AttributeParser.parse(child);
        Attribute attribute = attributes.get(REF);
        if(attribute != null) metaLink.setHref(attribute.getValue());
      }
      item.addLink(metaLink);
    }
  }
View Full Code Here

//        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();
       
        boolean newInput = true;
        for(int k = 0; k < form.getParams().size(); k++) {
View Full Code Here

  
    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)) {
        HTMLNode titleNode = searchTitleNode(root, node);
        if(titleNode != null) {
View Full Code Here

    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;
    }
    return null;
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;
      value = value.toLowerCase();
      if(value.indexOf(clazz) > -1) {//"post_message"
        return upParent(node, Name.TD);
      }
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.