Package org.vietspider.token.attribute

Examples of org.vietspider.token.attribute.Attributes


    if(link.equalsIgnoreCase(url)) return true;
    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;
View Full Code Here


        HTMLNode parent = node.getParent();
        if(parent != null && parent.isNode(Name.SPAN)) builder.append(' ');
      }
      break;
    case IMG:
      Attributes attributes = node.getAttributes();
      int value = calculateFromAttr(attributes.get("width"), 200);
//      value += calculateFromAttr(attributes.get("height"));
      if(value > 0) {
        score +=  value;
        paragraph++;
        sentence++;
      }
      break;
    case OBJECT:
      attributes = node.getAttributes();
      value = calculateFromAttr(attributes.get("width"), 400);
      if(value > 0) {
        paragraph++;
        sentence++;
        score += value;
      }
View Full Code Here

  }
 
  private String[] createAttributes(HTMLNode node) {
    if(node == null) return new String[0];
    try {
      Attributes attributes = node.getAttributes();
      String [] values = new String[attributes.size()];
      for(int i = 0; i < attributes.size(); i++) {
        Attribute attr = attributes.get(i);
        values[i] = attr.getName()+"=" + attr.getValue();
      }
      return values;
    } catch(Exception exp) {
    }
View Full Code Here

      ClientLog.getInstance().setMessage(tree.getShell(), exp);
   
  }

  private boolean searchSectionCSS(List<HTMLNode> commons, List<HTMLNode> list, HTMLNode node) {
    Attributes attributes = node.getAttributes();
    for(Attribute attr : attributes) {
      if(attr.getName().toLowerCase().equals("class")) {
        String value = attr.getValue().toLowerCase();
        if(value.indexOf("title") > -1 || value.indexOf("tieude") > -1) {
          list.add(node);
View Full Code Here

    }
    return false;
  }

  private boolean searchContentCSS(List<HTMLNode> commons, List<HTMLNode> list, HTMLNode node) {
    Attributes attributes = node.getAttributes();
    for(Attribute attr : attributes) {
      if(attr.getName().toLowerCase().equals("class")) {
        String value = attr.getValue().toLowerCase();
        if(value.indexOf("title") > -1 || value.indexOf("tieude") > -1) {
          list.add(node);
View Full Code Here

//    int countWord =
    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

    return true;
  }
 
  private int compareNodes(List<HTMLNode> links) {
    if(links.size() < 3) return 0;
    Attributes attributes = links.get(0).getAttributes();
    int counter = 1;
    for(int i = 1; i < links.size(); i++) {
      Attributes attributes1 = links.get(i).getAttributes();
      if(compareAttributes(attributes, attributes1)) counter++;
    }
    return (counter*100)/links.size() ;
  }
View Full Code Here

    }
    return false;
  }
 
  boolean isValidImage(HTMLNode node, int width, int height) {
    Attributes attributes = node.getAttributes();
    if(RenderNodeUtils.getIntAttrValue(attributes, "width") >= width) return true;
    if(RenderNodeUtils.getIntAttrValue(attributes, "height") >= height) return true;
    return false;
  }
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;
View Full Code Here

  public final void searchAnchors(HTMLNode node, List<HTMLNode> anchors) {  
    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

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.