100分求教:怎么能够得到html页面的实际显示值? ><之间的数据就是你要的阿 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用js 脚本可以实现, 比如 <script language="Javascript">function export_a(the_a){ var the_content=""; the_content=the_a.innerHTML; //这个是标签里面的文本 var newwin=window.open("about:blank","_blank",""); newwin.document.open(); newwin.document.write(the_content); newwin.document.close(); newwin=null;}</script>其他的部分,你自己改改,反正这样就可以提取文字了! 呵呵,好像有专门解析html的东东 可以自己做一个自定义函数,用来去除<>和</> 自定义函数解析html标记其实并不难大概100行的函数就可以了你可以排除<>之内的内容,把剩下的留下 private String removehtmltag(String htmlstr) { Pattern pat = Pattern.compile("\\s*<.*?>\\s*", Pattern.DOTALL | Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); Matcher m = pat.matcher(htmlstr); //再去掉其它所有html标记 String rs = m.replaceAll(" "); rs = rs.replaceAll(" ", " "); rs = rs.replaceAll("<", "<"); rs = rs.replaceAll(">", ">"); return rs; } <SCRIPT LANGUAGE="JavaScript"><!--var str='<a herf="www.sohu.com">sohu</a>sohu:<a herf="www.sina.com.cn">sohu</a>sina:<a '+ 'herf="www.ssina.163.com">163</a>163';str=str.replace(/<[^\/]*>([^<>]*)<\/\w>/img,"");alert(str);//--></SCRIPT> web路径问题!! [求助]关于路径的问题 花光所有家当求教JACOB调用OCX问题 jsp页面字符转换问题求助 毕业设计中的一些代码看不懂,里面有运行效果图,麻烦大家帮帮忙!~~~ 如何用JSP统计每天的首页访问量? grails 散分 问个傻傻的问题,如何接收某个servlet的response; 谁能提供一份jre(Java Runtime Environment)的中文文档!!! 生产环境的数据表维护问题 哪个好朋友能帮我理解一下javabean 生命周期的request tomcat运行servlet失败。。
<script language="Javascript">
function export_a(the_a)
{
var the_content="";
the_content=the_a.innerHTML; //这个是标签里面的文本 var newwin=window.open("about:blank","_blank","");
newwin.document.open(); newwin.document.write(the_content); newwin.document.close();
newwin=null;
}
</script>
其他的部分,你自己改改,反正这样就可以提取文字了!
大概100行的函数就可以了
你可以排除<>之内的内容,把剩下的留下
private String removehtmltag(String htmlstr) {
Pattern pat = Pattern.compile("\\s*<.*?>\\s*",
Pattern.DOTALL | Pattern.MULTILINE |
Pattern.CASE_INSENSITIVE);
Matcher m = pat.matcher(htmlstr);
//再去掉其它所有html标记
String rs = m.replaceAll(" ");
rs = rs.replaceAll(" ", " ");
rs = rs.replaceAll("<", "<");
rs = rs.replaceAll(">", ">");
return rs;
}
<!--
var str='<a herf="www.sohu.com">sohu</a>sohu:<a herf="www.sina.com.cn">sohu</a>sina:<a '+ 'herf="www.ssina.163.com">163</a>163';
str=str.replace(/<[^\/]*>([^<>]*)<\/\w>/img,"");
alert(str);
//-->
</SCRIPT>