主题 : 文章中 远程图片自动抓取 修改
级别: 童生
UID: 40297
积分:17 加为好友
威望: 1 精华: 0
主题:1 回复:16
注册时间:2012-10-31
在线时长:0
1#   发表于:2014-12-11 17:12:49  IP:116.76.*.*


默认 勾选了 添加 和编辑文章中的 远程图片自动抓取

修改图片路径匹配规则,忽略使用相对路径的图片。

public static  List<String> getImageSrc(String htmlCode) { 
        List<String> imageSrcList = new ArrayList<String>(); 
        String regular="<img(.*?)src=[\"\'](http[s]?:\\/\\/(.*?))[\"\']";
        Pattern p=Pattern.compile(regular,Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(htmlCode); 
        String src = null;
        while (m.find()) { 
           src=m.group(2);
            imageSrcList.add(src); 
        }
        return imageSrcList; 
    }
级别: 版主
UID: 70293
积分:78391 加为好友
威望: 1 精华: 0
主题:7 回复:68397
注册时间:2014-12-03
在线时长:0
2#   发表于:2014-12-11 17:14:18  IP:111.212.*.*
1
1 共1页