摘要: java中解析html jsoup是利器,其中部分用法如下:选择器 try { Document doc = Jsoup.parse(file,"utf-8"); Elements e = doc.select("img[src$=content_logo.png]"); //所有以content_logo.png结尾的img元素 Elements e2 = doc.select("a[href$=commentAnchor]"); //所有以commentAnchor结尾的a元素 System.out.println(e); } c 阅读全文
posted @ 2014-04-13 10:51 vance. 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 遇到一个需求,将页面中所有的title中所有的 "中新网"或"中新" 替换成"中国移动",代码如下:try { Document doc = Jsoup.parse(file,"utf-8"); String s = "哈哈中新网了啦"; System.out.println(s.replaceAll("中新.", "中国移动")); } catch (IOException e) { e.printStackTrace(); } 待改进 阅读全文
posted @ 2014-04-13 10:48 vance. 阅读(94) 评论(0) 推荐(0) 编辑