下载此文档

java 网页页面抓取标题和正文心得.docx


文档分类:IT计算机 | 页数:约7页 举报非法文档有奖
1/7
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/7 下载此文档
文档列表 文档介绍
java 网页页面抓取标题和正文心得
import ;
import ;
import ;
import .MalformedURLException;
import .URL;
import ;
import ;
import ;
import ;
import ;
public class WebContent
{
/**
* 读取一个网页全部内容
*/
public String getOneHtml(final String htmlurl) throws IOException
{
URL url;
String temp;
final StringBuffer sb = new StringBuffer();
try
{
url = new URL(htmlurl);
final BufferedReader in = new BufferedReader(new InputStreamReader((), "utf-8"));// 读取网页全部内容
while ((temp = ()) != null)
{
(temp);
}
();
}
catch (final MalformedURLException me)
{
("你输入的URL格式有问题!请仔细输入");
();
throw me;
}
catch (final IOException e)
{
();
throw e;
}
return ();
}
/**
*
* ***@param s
* ***@return 获得网页标题
*/
public String getTitle(final String s)
{
String regex;
String title = "";
final List<String> list = new ArrayList<String>();
regex = "<title>.*?</title>";
final Pattern pa = pile(regex, );
final Matcher ma = (s);
while (())
{
(());
}
for (int i = 0; i < (); i++)
{
title = title + (i);
}
retu

java 网页页面抓取标题和正文心得 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数7
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小23 KB
  • 时间2018-01-07