private static void func_httpGet(String url) {
HttpClient httpClient = new HttpClient();
try {
GetMethod getMethod = new GetMethod(url);
getMethod.getParams().setContentCharset("uft-8");
getMethod.setRequestHeader("Accept-Encoding", "uft-8,deflate, sdch");
getMethod.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
getMethod.setRequestHeader("Referer","http://www.0597kk.com/thread.php?fid=2");
getMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8");
getMethod.setRequestHeader("User-Agent",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0) QQBrowser/9.2.5063.400");
int statusCode = httpClient.executeMethod(getMethod);// 返回状态码200为成功,500为服务器端发生运行错误
// System.out.println("返回状态码:" + statusCode);
// 打印出返回数据,检验一下是否成功
InputStream inputStream = getMethod.getResponseBodyAsStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
StringBuffer stringBuffer = new StringBuffer();
String str = "";
while ((str = br.readLine()) != null) {
stringBuffer.append(str);
}
if (statusCode == 200) {
Document doc = Jsoup.parse(stringBuffer.toString());
Elements num = doc.select("div[class=readNum]").select("ul[class=cc]").select("em");
try {
System.out.println("当前阅读量:"+num.get(0).text());
} catch (Exception e) {
// TODO: handle exception
System.err.println("获取阅读量失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

最新文章

  1. 在centos上配置IP
  2. smarty string_format用法 取小数点后2位
  3. [Math] Deferred Acceptance Algorithm
  4. intanceof以及引出的__proto__和prototype
  5. OOP三个基本特征:封装、继承、多态
  6. oracle数据操纵语言(DML)data manipulation language(续集)
  7. 关于Java中return和finally谁先执行.
  8. 阻塞式和非阻塞式IO
  9. C# 将窗口移动到指定位置
  10. mysql union ,UNION RESULT
  11. BZOJ:1185: [HNOI2007]最小矩形覆盖
  12. 使用DDL触发器同步多个数据库结构
  13. Server:www121 Server:www120 Server:NWS_SP
  14. topcoder srm 693 div1 -3
  15. Storm 简单介绍
  16. xfs参数简介
  17. php文章tag标签的增删
  18. NHibernate参考文档、下载地址
  19. try catch finally 与continue的使用
  20. Java Json API:Gson使用简单入门

热门文章

  1. JavaWeb学习笔记——JavaBean的保存范围和删除
  2. 轻量级Image Library
  3. cmake安装MySQL
  4. php生成唯一随机码
  5. [CentOs]ip操作
  6. 弹出框一 之 基于bootstrap和jquery的自定义弹出框
  7. background的css 排列顺序写法?
  8. 关于linux vi命令替换的使用说明
  9. Vim 的 tab 设置
  10. 解析posix与perl标准的正则表达式区别 ---PHP