Exemplo n.º 1
0
 public void process(String url, HtmlNode node) {
   String href = node.getAttribute("href");
   if (href == null || href.toLowerCase().startsWith("javascript:")) {
     return;
   }
   try {
     String realUrl = UrlUtils.getUrl(url, href);
     if (realUrl.toLowerCase().indexOf("http://www.jokeji.cn") >= 0) {
       JokejiTest.processUrl(realUrl);
     }
   } catch (Throwable e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 2
0
 /**
  * 将HTML文档写入指定的输出流中
  *
  * @param out
  * @return void
  */
 public void write(OutputStream out) throws IOException {
   if (htmlDeclaration != null) {
     htmlDeclaration.write(out);
   }
   if (this.commentList != null) {
     for (HtmlNode n : commentList) {
       n.write(out);
     }
   }
   if (this.doctypeList != null) {
     for (HtmlNode n : doctypeList) {
       n.write(out);
     }
   }
   if (this.processingInstructionList != null) {
     for (HtmlNode n : processingInstructionList) {
       n.write(out);
     }
   }
   root.write(out);
 }
Exemplo n.º 3
0
 /**
  * 获取完整HTML文档
  *
  * @return String
  */
 public String toString() {
   StringBuffer sb = new StringBuffer();
   if (htmlDeclaration != null) {
     sb.append(this.htmlDeclaration.toStringBuffer());
   }
   if (this.commentList != null) {
     for (HtmlNode n : commentList) {
       sb.append(n.toStringBuffer());
     }
   }
   if (this.doctypeList != null) {
     for (HtmlNode n : doctypeList) {
       sb.append(n.toStringBuffer());
     }
   }
   if (this.processingInstructionList != null) {
     for (HtmlNode n : processingInstructionList) {
       sb.append(n.toStringBuffer());
     }
   }
   sb.append(root.toStringBuffer());
   return sb.toString();
 }