liuzejian4 发表于 2013-2-7 18:51:00

jsoup解析html基础

我用的是jsoup-1.6.3 jar
这个jar不需要别的jar包
//直接加载url            Document docs = Jsoup.connect("http://www.apache.org").get();            //获得body            Element body=docs.body();            //通过类jquery选择器选中html元素            Elements ls= body.select(".grid_3:contains(ActiveMQ) ");            // 遍历元素             for (Element el :ls){                  Elements lc=el.getElementsByTag("a");               for (Element cc :lc){                     System.out.println(cc.attr("href"));               }             }             }
这是jsoup的第一个例子,大体分析了下apache下的项目位置
页: [1]
查看完整版本: jsoup解析html基础