用这个工具jsoup
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.3</version>
java范例
Document document = Jsoup.parse(htmlContent);
Elements elements = document.getElementsByTag("img");
if (null != elements) {
for (Element element : elements) {
String src = element.attr("src");
src = src.replace(baseUrl, "");
src = src.replace("/api/", "/");
src = src.replaceAll("[&|?]access_token=.*$", "");
element.attr("src", src);
}
}