抓取网页内容
来源:互联网 发布:淘宝子账号有哪些权限 编辑:程序博客网 时间:2024/06/14 22:27
public static final String generate(final String url) {
if (StringUtils.isBlank(url)) {
return null;
}
Pattern pattern = Pattern.compile("(http://|https://){1}[\\w\\.\\-/:]+");
Matcher matcher = pattern.matcher(url);
if (!matcher.find()) {
return null;
}
StringBuffer sb = new StringBuffer();
try {
URL _url = new URL(url);
URLConnection urlConnection = _url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
if (StringUtils.isBlank(url)) {
return null;
}
Pattern pattern = Pattern.compile("(http://|https://){1}[\\w\\.\\-/:]+");
Matcher matcher = pattern.matcher(url);
if (!matcher.find()) {
return null;
}
StringBuffer sb = new StringBuffer();
try {
URL _url = new URL(url);
URLConnection urlConnection = _url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
sb.append(inputLine);
String url =
"http://www.bnu.edu.cn"
;//www.bnu.edu.cn";
02
URL theUrl=
new
URL(url);
03
openStream = theUrl.openStream();
04
//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
05
//构建输入流的的字符集必须和HTML源码中的 charset一致
06
bf =
new
BufferedReader(
new
InputStreamReader(openStream,
"utf-8"
));
07
String line =
null
;
08
while
((line = bf.readLine())!=
null
) {
09
System.out.println(line);
10
}
- JAVA 抓取网页内容
- 【JAVA】 抓取网页内容
- 网页内容抓取
- 网页内容抓取
- fsockopen 抓取网页内容
- JAVA 抓取网页内容
- 抓取网页内容
- lotusscript 抓取网页内容
- C# 抓取网页内容
- PHP抓取网页内容
- java 抓取网页内容
- 抓取网页内容
- 抓取网页内容
- 读取 抓取 网页内容
- 网页内容抓取
- C# 抓取网页内容
- 抓取网页内容
- php抓取网页内容
- Huffman 编码压缩算法
- tomcat CATALINA_BASE multi instance on windows 在window下启动多个tomcat实例
- 自己写的一个图片上传类,很方便可以指定目录,系统自动创建目录,可以指定名字,类型,大小
- oracle 实例与数据库的概念
- 将GridView和数据库查询结果绑定起来后,点击查询出了结果。但是点击第二面或者其他的,就直接变空白了。(已经解决)
- 抓取网页内容
- myeclipse连接oracle出现ora-12705错误的解决办法
- UIImageView增加点击事件
- input输入框无边框和调结宽度
- MyBatis学习 之 三、SQL语句映射文件-增删改查、参数、缓存
- 正确使用stl map的erase方法
- CSS hack
- 推荐的RS232保护电路
- 黑马程序员---------------