抓取内容如何提取内容

chyx413332087 2008-07-23 03:16:25
取网站的内容过来,可我只要theAds[1]=''中的内容,请问如何提取啊,
<script>theAds=new Array();
shu = 28
dot=''
theAds[1]='<tr bgcolor=#FFFF00 class=style52 onmouseover=javascript:this.bgColor=\'#FFCCFF\' onmouseout=javascript:this.bgColor=\'#ffff00\'><td class=style6 width=96><a href=http:\/\/www.baby0917.cn target=_blank>猪猪传说</a></td><td class=style6 width=107>59.34.197.182</td><td class=style5 width=190><span class=style93>2008年/7月/23日/14点/30分开放</span></td><td class=style6 width=80>爽爽爽爽爽</td><td class=style49 width=266>崭新装备pk不封速度-<span class=style74>推荐</span></td><td width=128 class=style6 width=128>客服QQ:上线送分身术</td><td class=style6><A href=http:\/\/www.baby0917.cn target=_blank>点击查看</a></td></tr>'
adshu=shu+1
var idx;
var ballball = new Array(shu);
ballball = this.Quickpick();
for(idx = 1; idx < adshu; idx++){
document.write(dot+theAds[ballball[idx]]);
if (idx < shu){document.write('')}}
document.write(dot+theAds2);</script>
...全文
124 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chyx413332087 2008-07-23
  • 打赏
  • 举报
回复
你写的正则表达式,有点问题,你用我内容看,就找不出了,
theAds[1]=' <tr bgcolor=#FFFF00 class=style52 onmouseover=javascript:this.bgColor=\'#FFCCFF\' onmouseout=javascript:this.bgColor=\'#ffff00\'> <td class=style6 width=96> <a href=http:\/\/www.baby0917.cn target=_blank>猪猪传说 </a> </td> <td class=style6 width=107>59.34.197.182 </td> <td class=style5 width=190> <span class=style93>2008年/7月/23日/14点/30分开放 </span> </td> <td class=style6 width=80>爽爽爽爽爽 </td> <td class=style49 width=266>崭新装备pk不封速度- <span class=style74>推荐 </span> </td> <td width=128 class=style6 width=128>客服QQ:上线送分身术 </td> <td class=style6> <A href=http:\/\/www.baby0917.cn target=_blank>点击查看 </a> </td> </tr>'

我用其他的方式解决了,
还是用htmlParse的方式,谢谢你
parellax 2008-07-23
  • 打赏
  • 举报
回复
up
rascalboy520 2008-07-23
  • 打赏
  • 举报
回复

public static void do10(){
String str="theAds[1]='fdjksajfldsajf'";
Pattern pattern = Pattern.compile("theAds\\[\\d+\\]='([^']+)'",Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
Matcher m = pattern.matcher(str);
while(m.find()){
System.out.println(m.group(1));
}
}
chyx413332087 2008-07-23
  • 打赏
  • 举报
回复
正则表达式如何写,赐教。。
rascalboy520 2008-07-23
  • 打赏
  • 举报
回复
用正则吧,
chyx413332087 2008-07-23
  • 打赏
  • 举报
回复
我是用的HTMLPaser解析,问题是
heAds=new Array();

shu = 28
dot=''
theAds[1]='
adshu=shu+1
var idx;
var ballball = new Array(shu);
ballball = this.Quickpick();
for(idx = 1; idx < adshu; idx++){
document.write(dot+theAds[ballball[idx]]);
if (idx < shu){document.write('')}}
document.write(dot+theAds2); </script>
像这种好像不会过滤掉
海诗美妆 2008-07-23
  • 打赏
  • 举报
回复
可以使用HTMLPaser来解析HTML文本,
很方便!

http://htmlparser.sourceforge.net/

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧