找回密码
 加入
搜索
查看: 5212|回复: 6

[效率算法] 求正则高手帮我截取3GQQ信息(已解决)

[复制链接]
发表于 2012-1-16 11:14:29 | 显示全部楼层 |阅读模式
本帖最后由 yeqing880 于 2012-1-17 12:14 编辑

以下为post内容  求教3G QQ信息的正则
<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta http-equiv="Cache-control" content="max-age=1700" />
        <meta name="viewport" content="width=device-width; initial-scale=1.3;  minimum-scale=1.0; maximum-scale=2.0"/>
        <meta name="MobileOptimized" content="240"/>
        <meta name="format-detection" content="telephone=no" />
        <title>与crrl 2聊天-3GQQ</title>
<style>
/* Reset */
body,div,p,a,table,textarea,form,img,ul,li{ margin:0; padding:0; text-justify:inter-ideograph; font-family: 'Microsoft YaHei', 'Arial', '宋体';}
li{ list-style:none; text-indent:0;}
img, a img{ border:none; }
a{ text-decoration:none; color:#0051a4;}

/* Common */
body{ font-size:14px; width:240px; margin:0 auto; border:1px solid #c6c6c6; }
.links-b-u a{ color:#0051a4; text-decoration:underline; }
.links-b-u span{ font-size:12px; padding-left:2px; }
.btn{ border:medium none; height:24px; margin:0; padding:0; color:#1771cd; line-height:24px; }
.btn-b-2{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_2.png) no-repeat scroll 0 0 transparent; width:42px; }
.btn-b-3{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_3.png) no-repeat scroll 0 0 transparent; width:59px; }
.btn-b-3-5{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_3_5.png) no-repeat scroll 0 0 transparent; width:70px; }
.btn-b-4{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_4.png) no-repeat scroll 0 0 transparent; width:76px; }
.btn-b-5-5{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_5_5.png) no-repeat scroll 0 0 transparent; width:107px; }
.btn-b-6{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_6.png) no-repeat scroll 0 0 transparent; width:108px; }
.btn-b-8{ background:url(http://source1.qq.com/3gqq/wap/images/btn_b_8.png) no-repeat scroll 0 0 transparent; width:158px; }
select{ height:24px; color:#060101; vertical-align:middle; }
.bm-gray{ border-bottom:1px solid #cdcdcd; }
.bm-white{ border-bottom:1px solid #ffffff;}
.bm-hoar{ border-bottom:1px solid #f0f2f3;}
.bm-blue{ border-bottom:1px solid #dbe9f1;}
.bm-blue2{ border-bottom:1px solid #9fc6ec;}
.tp-white{ border-top:1px solid #ffffff; }
.tp-gray{ border-top:1px solid #cdcdcd; }
.separate{ margin:0 5px; }
.separate-l{ margin:0 8px; }
a.ft-cl{ color:#ff6600; }
.ft-cl2{ color:#f19365; }
.ft-cl3{ color:#aa0000; }
.ft-cl4{ color:#74675d; }
.ft-cl5{ color:#9b9b9b; }
.ft-cl6{ color:#8e8e8e; }
.ft-cl7{ color:#959595; }
.ft-s-cl{ color:#7a7a7a; }
.ft-s{ font-size:12px; }
.ft-s-u{ font-size:12px; text-decoration:underline; }
.ft-s-gray{ color:#a7a7a7; font-size:12px; }
.ft-limit{ display:inline-block; width:90px; overflow:hidden; vertical-align:middle; word-break:keep-all; text-overflow:ellipsis; }
input.tx{ height:20px; border:1px solid #78bee7; line-height:20px; color:#000000; vertical-align:baseline; }
.bg-gray-info{ padding:4px 10px; border-top:1px solid #ffffff; background:#f0f2f3; }
.bg-blue{ background:#d9e9f1;  padding:8px 11px;}
input.tx-s{ width:70px; }
input.tx-m{ width:120px; }
input.tx-l{ width:170px; }
input.tx-f{ width:97%; }
textarea{ border:1px solid #78bee7; width:215px; font-size:14px; }
.sp-w{ width:133px; display:inline-block; text-align:center; }
.mg-r-8{ margin-right:8px; }

/* Qbar */
#qbar{ background:url(http://source1.qq.com/3gqq/wap/images/bg_qbar.png) repeat-x #b3e2fb; height:23px; line-height:23px; border-bottom:1px solid #2d91cd; padding:0 

10px; }
        #qbar a{ margin-right:3px; }
        #qbar img{ vertical-align:text-bottom; padding:0; margin:0; width:16px; height:16px; }
        
/* Footer */
#footer{ text-align:center; background:#dbe9f1; border-top:1px solid #9fc6ec; padding:8px; }
#footer p{ height:24px; line-height:24px; }


/* Module Head */
.module-head{ font-weight:bold; background:url(http://source1.qq.com/3gqq/wap/images/module_head.png) repeat-x #bbdef6; padding:0 10px; height:25px; line-height:25px; 

border-top:1px solid #dbe9f1; border-bottom:1px solid #9fc6ec; }

/* Main Module */
.main-module{ padding:4px 10px; color:#060101; }
        .main-module p{ line-height:24px; }
        .main-module img{ margin-right:3px; }
        .module-nom img{ vertical-align:text-bottom; margin:0; }
        .main-module a{ color:#0051a4; }
        .main-module a.ft-cl{ color:#ff6600; }

/* Infocard */
.infocard{ background:url(http://source1.qq.com/3gqq/wap/images/bg_infocard.png) no-repeat #2ca2e6; height:73px; border-top:1px solid #a2ddf5; border-bottom:1px solid 

#146fae; padding:0 10px; }
        .infocard .hd{ line-height:29px; color:#060101; height:29px; }
        .infocard .hd a{ font-size:12px; margin-left:8px; }
        .infocard .bd{height:36px; line-height:36px; font-weight:bold; color:#060101; }
                .infocard img{ height:32px; width:32px; margin-right:8px; border:2px solid #62e4f3; vertical-align:top; }
                .infocard .bd a{ margin-left:8px; font-weight:normal; }

/* Main Nav */
.main-nav{ background-color:#a8d8fb; height:29px; line-height:29px; color:#9b9b9b; }
.main-nav a.selected{ color:#060101; border:0 none; font-weight:bold; }
.main-nav-4 a{ padding:0 10px; }
.main-nav-3 a{ padding:0 20px; }
.main-nav-2 a{ padding: 0 24px; }

/* Search Box */
.search-box{ padding:7px 10px; vertical-align:baseline; }
.search-box select{ width:70px; }

/* Chat List */
.chat-list{ color:#060101; }
        .chat-list p, .chat-list form{ height:39px; line-height:39px;  padding:0 10px; width:220px; overflow:hidden; vertical-align:middle; word-break:keep-all; text-

overflow:ellipsis;  }
        .chat-list p.bg, .chat-list form.bg{ background:#f0f2f3; }
        .chat-list p img{ vertical-align:middle; }
        .chat-list p.bg img{ border:1px solid #bebfbf; }
        .sign img{ border:0 none; }
        .chat-list .name{ margin-left:12px; color:#060101; }
        .chat-list .sign{ margin-left:10px; color:#9b9b9b;}
        .chat-list .no{ color:#9b9b9b; margin-left:8px; }
        .chat-list .btn-open{ color:#9b9b9b; margin-right:10px; }
        .group-list p, p.group-list{ height:31px; line-height:31px; }
        .chat-list p img.group-close{ height:9px; width:9px; border:0 none; vertical-align:baseline; margin-right:7px; }
        .chat-list p img.group-open{ height:9px; width:9px; border:0 none; vertical-align:baseline; margin-right:7px; }

/* Page Nav */
p.page-nav{ height:30px; line-height:30px; }
.page-nav a{ padding:0 5px 0 0; }
.page-nav input.tx{ width:30px; }
        
.rst-list{ padding-bottom:3px; }
.rst-list .name{ color:#0051a4; }
        
.header{ border-bottom:1px solid #146fae; border-top:1px solid #84e2f9; background:url(http://source1.qq.com/3gqq/wap/images/bg_header.png) repeat-x; height:22px; 

line-height:22px; padding:0 10px; }

.rst-tips{ border-top:1px solid #ffffff; border-bottom:1px solid #ffffff; background:#f0f2f3; color:#060101; padding:0 10px; height:24px; line-height:24px; }

.rst-info{ padding:6px 10px; line-height:24px; color:#060101; background:#ffffcc; border-top:1px solid #ffcb99; border-bottom:1px solid #ffcb99; }
        .rst-info img{ vertical-align:middle; margin-right:3px; }
        .rst-info a{ line-height:24px; }
        
img.qqshow{ border:1px solid #cdcdcd; }
.line-h p{ line-height:28px; }

/* Baseinfo Face */
.baseinfo-face{ line-height:26px; margin:2px 0; }
.baseinfo-face img{ border:1px solid #cdcdcd; vertical-align:middle; }

.module-title{ background:#dbe9f1; border-bottom:1px solid #9fc6ec; padding:0 10px; line-height:24px; height:24px; }

/* Emotion */
.emotion{ padding:4px 10px 4px 6px; }
.emotion .btn{ margin-left:4px; text-align:left; padding-left:3px; }
</style></head>

<body>
<style type="text/css">   .qbar { line-height:1.3}   .qbar a{ text-decoration:none; color:#0051A4;}  .qbar img{ margin-right:2px; vertical-align:middle;}   

.qbar_broadcast{background:#FFF9B7;padding:3px 5px; border-bottom:1px solid #ccc; line-height:1.5;display:block};  </style><span class="qbar" ><a  

href="http://q32.3g.qq.com/g/s?new3gqq=true&aid=nqqchatMain&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0"><img  

src="http://117.34.6.172/qbar/qbar_qqui_online.gif" alt="聊天"/>QQ</a><a  href="http://sqq2.3g.qq.com/s?

aid=qbar&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0"><img  src="http://117.34.6.172/qbar/qbar_wapsqq.gif" alt="超级QQ"/>(0)</a><a  

href="http://ti2.3g.qq.com/g/s?aid=h&g_f=5407&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0"><img  

src="http://117.34.6.172/qbar/qbar_microblog.gif" alt="微博"/>(0)</a><a  href="http://pay.3g.qq.com/msgcenter.jsp?

g_f=6560&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0"><img  src="http://117.34.6.172/qbar/qbar_mpay.gif" alt="钱包"/>(0)</a><a  

href="http://qbar.3g.qq.com/g/qbar/qbar_list.jsp?sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0">>></a><br /><span class="qbar_broadcast" ><a  

href="http://qbar.3g.qq.com/g/system_msg/system_msg.jsp?sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0&id=995"><img  

src="http://117.34.6.172/qbar/qbar_sysmsg_1.gif" alt="广播"/> 买卖宝迎春节送福袋啰</a></span></span>
<div class="header">
        <p>和<a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqUserInfo&u=232327265&on=1">远程2</a>聊天中 <a 

href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqChat&u=232327265&on=1" class="ft-s-u">刷新消息</a></p>
</div>


<div class="bg-blue line-h">
        <form action="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF" method="post">
                <p><textarea rows="3" name="msg"></textarea></p>
                <input type="hidden" name="u" value="232327265"/>
                <input type="hidden" name="saveURL" value="0"/>
                <input type="hidden" name="do" value="send"/>
                <input type="hidden" name="on" value="1"/>
                <input type="hidden" name="saveURL" value="0"/>
        <p><input type="submit" name="aid" value="发送" class="btn btn-b-6 mg-r-8"/><input type="submit" name="aid" value="表情" class="btn btn-b-2"/></p>
                <input type="hidden" name="num" value="232327265"/>
                <input type="hidden" name="do" value="sendsms"/>
            <p><input type="submit" name="aid" value="发送短信给Ta" class="btn btn-b-8"/></p>
    </form>
</div>

<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2 10:48:58
        </p>
        <p>cx sfas </p>
</div>
<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2 10:48:44
        </p>
        <p>cx </p>
</div>
<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2 10:48:02
        </p>
        <p>test </p>
</div>

<div class="main-module bm-gray">
        <p><a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqchatMain&on=1&g_f=1657">返回好友列表</a></p>
    <p><a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqHistory&u=232327265">聊天记录</a></p>
        <p><a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqUserInfo&u=232327265&on=1">好友资料</a></p>
        <p><a href="http://t.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=aurljump&k=gqz&tuin=232327265&g_f=12185">好友微博</a></p>
</div>

<div class="main-module bm-gray">
<p><a href="http://wap.3g.qq.com/g/s?aid=adp_click&ad_s=L&pid=76&adid=70215&adpid=57469&adactid=57216&go=http%3A%2F%2Fwap.datou.com%2Fnews

%2Fdtsc.do%3Fcf%3Dqq6&sid=AaYGIltkybKRuou1FFKDOFSF">名牌!正品授权名鞋半价销售</a><br/></p>
<p><a href="http://wap.3g.qq.com/g/s?aid=adp_click&ad_s=L&pid=168&adid=33685&adpid=55916&adactid=55657&go=http%3A%2F%2Fsqq.3g.qq.com

%2Ftemplate%2Findex.jsp%3Fg_f%3D9307%26sid%3DAaYGIltkybKRuou1FFKDOFSF&sid=AaYGIltkybKRuou1FFKDOFSF">[荐]QQ等级加速省钱秘诀</a><br/></p>
<p><a href="http://wap.3g.qq.com/g/s?aid=adp_click&ad_s=L&pid=5&adid=50373&adpid=56220&adactid=55961&go=http%3A%2F%2Fmg.3g.qq.com%2Flogin.jsp

%3Fcpid%3D916%26gameid%3D126%26cid%3D3g%26sid%3DAaYGIltkybKRuou1FFKDOFSF&sid=AaYGIltkybKRuou1FFKDOFSF">[英雄]而过回眸一笑群芳失色</a><br/></p>
<p><a href="http://wap.3g.qq.com/g/s?aid=adp_click&ad_s=L&pid=237&adid=70013&adpid=57422&adactid=57169&go=http%3A%2F%2Fminutemaid.3g.qq.com

%3Fsid%3DAaYGIltkybKRuou1FFKDOFSF&sid=AaYGIltkybKRuou1FFKDOFSF">动手摇一摇赢美汁源果粒好礼</a><br/></p>
</div>
<div class="main-module">
        <p><a href="#qbar"><img width="13" height="13" border="0" src="http://source2.qq.com/3gqq/images/img_turn_top.png"/>回顶部</a></p>
    <p><a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqSelf">设置</a><span class="separate">|</span><a href="http://q32.3g.qq.com/g/s?

sid=AaYGIltkybKRuou1FFKDOFSF&aid=find">查找</a><span class="separate">|</span><a href="http://wap.3g.qq.com/g/s?

sid=AaYGIltkybKRuou1FFKDOFSF&aid=wapsupport&fid=435">反馈</a><span class="separate">|</span><a href="http://q32.3g.qq.com/g/s?

sid=AaYGIltkybKRuou1FFKDOFSF&aid=logout&from=logout">更改用户</a></p>
</div><div id="footer">
        <p><<a href="http://q32.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nqqchatMain&g_f=1657&g_ut=1&gutswicher=1">普通版</a><span 

class="separate">|</span>3G版></p>
<div class="top"><a href="http://info50.3g.qq.com/g/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=index&login=false">手机腾讯网</a>-<a href="http://info50.3g.qq.com/g/s?

sid=AaYGIltkybKRuou1FFKDOFSF&aid=navigation">导航</a>-<a href="http://app.qq.com/g/?g_f=990281&sid=AaYGIltkybKRuou1FFKDOFSF">软件</a>-<a 

href="http://pt5.3g.qq.com/s?sid=AaYGIltkybKRuou1FFKDOFSF&aid=nLogout">退出</a><br /></div><div class="zt"><a href="http://sqq.3g.qq.com/s?

aid=qbar&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0">超Q(0)</a>.<a href="http://info60.z.qq.com/infocenter_v2.jsp?

g_f=6438&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0">空间(0)</a>.<a href="http://house60.3g.qq.com/g/s?

aid=home_self&g_f=595&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0">家园(2)</a>.<a href="http://ti2.3g.qq.com/g/s?

aid=h&g_f=6439&sid=AaYGIltkybKRuou1FFKDOFSF&3G_UIN=2507570368&saveURL=0">微博(0)</a><br /></div><div class="top"><form 

action="http://wap.soso.com/sweb/search.jsp?st=input&g_f=6215&sid=AaYGIltkybKRuou1FFKDOFSF" method="post"><a href="http://wap.soso.com/navi.jsp?

sid=AaYGIltkybKRuou1FFKDOFSF&g_f=6228">搜搜</a><input name="key" type="text"  size="8"  style="width:80px"   value="王菲大便歌"  maxlength="40"/><input 

type="submit" value="搜网页" /><br />小Q报时(11:05)<br /></form></div></div>





</body>
</html>
有效内容在206 -220 行之间!!! 谢谢大家了
发表于 2012-1-16 11:59:28 | 显示全部楼层
是这一整段吗?
<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2&nbsp;10:48:58
        </p>
        <p>cx sfas </p>
</div>
<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2&nbsp;10:48:44
        </p>
        <p>cx </p>
</div>
<div class="main-module bm-gray">
        <p class="ft-s ft-cl2">
远程2&nbsp;10:48:02
        </p>
        <p>test </p>
</div>
发表于 2012-1-16 12:13:44 | 显示全部楼层
(?:\<div.+ay">\s*<p (?s).+?</div>\s+)+
一整段含标签的
<div.+ay">\s*<p (?s).+?</div>
分3个含标签元素的
cl2">\s+(.+)\s+</
分3个无标签元素的
发表于 2012-1-16 12:14:49 | 显示全部楼层
看得头大, 我完全看不出应该'取'什么信息?
也求楼主再给多点提示?
发表于 2012-1-16 12:19:03 | 显示全部楼层
看得头大, 我完全看不出应该'取'什么信息?
也求楼主再给多点提示?
user3000 发表于 2012-1-16 12:14



    在 204 及 221 行里面含有论坛使用的代码 [ color=Red ] 、[ /color ] 因此我在 2# 贴出了疑问
 楼主| 发表于 2012-1-16 15:03:50 | 显示全部楼层
回复 5# afan

谢谢您这么仔细,A版 真的非常感谢您 的回复

您说得对 是204 - 221里面...
 楼主| 发表于 2012-1-17 12:13:50 | 显示全部楼层
问题解决 谢谢版主帮忙  再次感谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-19 17:40 , Processed in 0.079793 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表