Jsoup主页:http://jsoup.org/

在Blog.java 加入

    private List<String> imageList=new LinkedList<String>(); // 博客里存在的图片,主要用于列表展示的缩略图

    for(Blog blog:blogList){
            List<String> imageList=blog.getImageList();
            String blogInfo=blog.getContent();
            Document doc=Jsoup.parse(blogInfo);
            Elements jpgs=doc.select("img[src$=.jpg]");
            for(int i=0;i<jpgs.size();i++){
                Element jpg=jpgs.get(i);
                imageList.add(jpg.toString());
                if(i==2){
                    break;
                }
            }
        }
View Code

相关文章: