jsoup

引用的是 Jsoup  包

 

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class test {
    public static void main(String[] args) throws IOException {
        Document document=Jsoup.connect("http://www.waduanzi.com/page/1").get();
        Elements elements=document.select("div[class=panel panel20 post-item post-box]>div[class=item-detail]>h2[class=item-title]>a[class=cd-title-link]");
        for(Element element:elements){
            System.out.print(element.html());
            System.out.println(element.absUrl("href"));
//            System.out.println(element.attr("href"));

        }


    }
}

  

posted @ 2018-01-21 15:56  m97i  阅读(111)  评论(0编辑  收藏  举报