找回密码
 加入
搜索
查看: 5209|回复: 8

[AU3基础] (正则表达式练习题1)如何获取一个网页中的某一段内容?欢迎进来练练手。(已解决)

  [复制链接]
发表于 2010-12-3 13:14:15 | 显示全部楼层 |阅读模式
本帖最后由 yiruirui 于 2010-12-4 11:13 编辑

举例:
http://www.game333.net/game/CSS.htm

从这个网页中读取它的源文件,用 InetRead就OK,从读到的内容中截取一段内容:
截取结果是这样:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td>
                                <script src="/js/webThunderDetect.js"></script>
                                <script src="/js/base64.js"></script>
                                <script language="javascript">
                                var thunderArr = new Array;
                                                                        thunderArr['9'] = "http://9.game333.net/CSS.exe";  
                                                                        thunderArr['8'] = "http://8.game333.net/CSS.exe";  
                                                                        thunderArr['5'] = "http://5.game333.net/CSS.exe";  
                                                                        thunderArr['10'] = "http://10.game333.net/CSS.exe";  
                                                                var thunder_pid = "19985";
                                var thunder_type = "08";
                                var restitle = "WEB迅雷下载";
                                </script>
                                          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td colspan="2">
                                                  <span class="fb downid2">CS:S 起源僵尸服 下载地址</span></td>
                        </tr>
                        <tr>
                          <td width="70"> </td>
                          <td><div class="bt-down">
                                <h3><a href="/bt/CSS.exe.torrent" onclick="getCnt();" rel="nofollow">[<b>CS:S 起源僵尸服</b>]CSS.exe.torrent </a><span style="color: #ccc;">(110KB)</span></h3></div></td>
                        </tr>
                </table></td>
              </tr>
            </table>
刚好在<table>与</table>之间的内容,麻烦新手老手高手菜鸟都动手练习一下吧!
PS:可以用大A版主的正则测试工具进行测试,注意一点通用性就OK!
发表于 2010-12-3 13:35:24 | 显示全部楼层
(?s)<tr>\s+<td>\s+<s.+?(?=</table>\s+)
 楼主| 发表于 2010-12-4 11:12:20 | 显示全部楼层
回复 2# afan


    感谢A版主!也期待更多的人参与进来!
发表于 2010-12-17 13:27:03 | 显示全部楼层
回复 2# afan
对于<script src="/js/webThunderDetect.js"></script>
用(?s)<tr>\s+<td>\s+<s.+?(?=</table>\s+)的匹配的问题:
其中+<s 匹配<script 中的<s;
.+匹配至少一个任意字符,那之后的? 匹配什么.
(?=</table>\s+是匹配最后的</table>之前的一大段吗?
发表于 2010-12-25 12:19:12 | 显示全部楼层
没有搞明白
发表于 2011-2-25 16:59:56 | 显示全部楼层
正则不会啊,悲剧。。
发表于 2011-2-25 17:18:23 | 显示全部楼层
stringregexp($ipp, '(?U)<table>([\s\S]+)</table>', 3, 1)
抓取<table> 和</table> 之间任何字符,包括换行
发表于 2013-5-7 10:36:33 | 显示全部楼层
完全不能理解啊 唉
发表于 2013-5-8 07:10:03 | 显示全部楼层
不明白,名副其实新手上路。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-29 05:29 , Processed in 0.086826 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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