读书人

怎么从html中提取url地址

发布时间: 2013-09-05 16:02:06 作者: rapoo

如何从html中提取url地址
诸如
"<a href="/content/content.php?p=2_5_3" target="_self">??????è?????</a></dd>
<a href="/content/content.php?p=2_5_3" target="_self">??????è?????</a></dd>
......"
之类

变为
“/content/content.php?p=2_5_3
/content/content.php?p=2_5_3
......"
正则表达式 html url
[解决办法]
用jquery获取 doc的元素
[解决办法]

引用:
用jquery获取 doc的元素


用jquery获取<a>元素的href属性
[解决办法]
正则就能解决。。

String str="\"<a href=\"/content/content.php?p=2_5_3\" target=\"_self\">";
System.out.println(str);
Matcher m = Pattern.compile("\"<a href=\"(.*?)\" ").matcher(str);
while(m.find()){
System.out.println(m.group(1));
}

读书人网 >Java相关

热点推荐