找回密码
 加入
搜索
查看: 10159|回复: 18

[系统综合] 如何用正则提取该网页中表格的第3行至第11行的第1列内容并显示?

 火.. [复制链接]
发表于 2011-6-7 16:25:26 | 显示全部楼层 |阅读模式
本帖最后由 newuser 于 2011-6-8 12:54 编辑

这个是页面截图,我要提取的是红色部分.

网页源代码如下:
<html>

<head>
<style type="text/css">
<!--
td{font-size: 12px;line-height:17px;}
body{font-size: 12px;line-height:17px;}
A:link{text-decoration:none;color:#008040}
A:visited{text-decoration:none;color:#0080FF}
A:active{text-decoration:none}
A:hover{text-decoration:underline;color:#008040}
*{ margin:0; padding:0;}
.wrap{ width:950px; margin:0 auto; background:url(http://img.qihoo.com/images/2008/360360/t360bg.gif) top repeat-x; }
.wrap{ width:950px; margin:0 auto; background:#ffffff; }
.content{ width:100%; clear:both; background:url(http://img.qihoo.com/images/2008/360cn090112/contentbg.gif) repeat-y;}
.leftBox{ width:277px; float:left;}
div.border{ border:1px solid #bdd4e6; border-bottom:none; border-top:none;}
div.lbg{ background:#fff url(http://img.qihoo.com/images/2008/360cn090112/lbg.gif) top repeat-x;}
.wCon{ width:245px; margin:0 auto;}
.warp{width:917px;margin:0px auto;}
.left{float:left;display:inline;margin-bottom:9px; }
.left{width:680px;}
.left .content{border:1px solid #D3D3D3;background:#F7FCFF;border-bottom:0px;}

h1{margin:0px;padding:0px;font-size:12px;}

td.PageList
{
    height:16;
}
-->
</style>

<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>SEP安装指南</title>
</head>

<body bgcolor="#C0C0C0">

<div align="center">
        <table border="0" cellpadding="0" cellspacing="0" width="800" height="603" bgcolor="#FFFFFF">
                <!-- MSTableType="layout" -->
                <tr>
                        <td valign="top" colspan="3" height="200">
                        <!-- MSCellType="ContentHead" -->
                        <img border="0" src="images/layout_01.gif" width="297" height="190"><img border="0" src="images/layout_02.gif" width="77" height="190"><img border="0" src="images/layout_03.gif" width="354" height="190"><img border="0" src="images/layout_04.gif" width="72" height="190"></td>
                </tr>
                <tr>
                        <td></td>
                        <td></td>
                        <td height="2"></td>
                </tr>
                <tr>
                        <td valign="top" align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/lanmu_biao.gif" width="18" height="16">安全播报    
                        <a href="virus_alert.html">更多信息</a></td>
                        <td valign="top" align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/lanmu_biao.gif" width="18" height="16">Microsoft安全视频</td>
                        <td valign="top" height="25" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <img border="0" src="useimg/lanmu_biao.gif" width="18" height="16">常用补丁  
                        <a href="patchs_download.htm">更多连接</a></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5">
                                                <a href="virusalerter/jiamian.txt">假面”木马化身快捷方式 
                        可绕过绝大多数安全软件(10.7.17)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/security.zip">保护您的 PC</a></b></td>
                        <td height="25" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <span lang="zh-cn" style="margin: 0; padding: 0">
                        <a style="text-decoration: none; color: #008040; margin: 0; padding: 0" href="patchs/Office2003SP2-KB887616-FullFile-CHS.exe">
                        Office2003 SP2补丁包</a></span></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="virusalerter/NewTrojanDown.txt">国家计算机病毒中心发现“木马下载器”新变种(10.7.19)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b>
                        <a href="MicrosoftVideo/Protect_your_household_from_online_fraud.zip">
                        保护您的家庭免遭网络欺诈</a></b></td>
                        <td height="25" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <span lang="zh-cn" style="margin: 0; padding: 0">
                        <a style="text-decoration: none; color: #008040; margin: 0; padding: 0" href="patchs/WindowsXP-SP2-CHS.exe">
                        Windows XP SP2  中文版</a></span></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="virusalerter/badbackdoor_10.txt">恶性后门病毒(10.8.30)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/keep_your_computer_up_to_date.zip">
                        保持您的计算机最新</a></b></td>
                        <td height="25" align="left">
                                                <span lang="zh-cn">
                                                <a href="patchs/WindowsXP-KB936929-SP3-x86-CHS.exe">
                                                Windows XP SP3  中文版</a></span></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="virusalerter/guixing.txt">“鬼影”病毒向安全厂商下战书 
                        360最新版可拦截(10.3.22)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/Privacy.exe">在网上保护您的隐私和个人信息</a></b></td>
                        <td height="25" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <span lang="zh-cn" style="margin: 0; padding: 0">
                        <a style="text-decoration: none; color: #008040; margin: 0; padding: 0" href="patchs/WindowsServer2003-KB914961-SP2-x86-CHS.exe">
                        WinServer2003SP2中文版</a></span></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="virusalerter/meiying.txt">“魅影”病毒疯弹色情广告 
                        360系统急救箱可彻杀(10.5.17)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/Viruses-worms.exe">防范病毒和蠕虫</a> </b></td>
                        <td height="25" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <a style="text-decoration: none; color: #008040; margin: 0; padding: 0" href="360safe/hotfix20080328.rar">
                        360补丁集<span lang="zh-cn" style="margin: 0; padding: 0">20080328</span></a></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="patchs_download.htm">最新补丁更新(10.5.17)</a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/Newsgroups.exe">使用网上新闻组</a></b></td>
                        <td height="26" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <img border="0" src="useimg/lanmu_biao.gif" width="18" height="16"><span style="font-size: 9pt">常用软件  
                        <a href="tools_download.htm">更多连接</a></span></td>
                </tr>
                <tr>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a id="utitle_18035" target="_blank" href="virusalerter/jishengcong.txt">寄生虫”木马疯狂流行 
                        国内仅360能查杀(10.6.11) </a></td>
                        <td align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/SpamDomestic.zip">减少垃圾邮件</a></b></td>
                        <td height="26" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <a href="tools/arswp3_x86.exe">Windows清理助手</a></td>
                </tr>
                <tr>
                        <td width="338" align="left">
                        <!-- MSCellType="NavBody" -->
                        <img border="0" src="useimg/blue_bullet.gif" width="5" height="5"><a href="virusalerter/Trojan_agent.txt">国家计算机病毒中心:“代理木马”新变种肆虐</a>(10.6.28)</td>
                        <td width="329" align="left">
                        <!-- MSCellType="NavBody" -->
                        <b><a href="MicrosoftVideo/ChildSafety.zip">教您的孩子注意上网安全</a></b></td>
                        <td height="26" align="left">
                        <!-- MSCellType="NavBody2" -->
                        <a href="360safe/75.exe">360安全卫士V7.3正式版</a></td>
                </tr>
                <tr>
                        <td valign="top" rowspan="4" colspan="2">
                        <!-- MSCellType="NavBody" -->
                        <p align="center">
                        <font size="4"><b><br>
 </b></font><p align="center">
                        <b><font size="6">
                        <a href="Symantec%20Endpoint%20Protection%20安装.htm">桌面安全项目客户端软件安装指南</a></font></b><p align="center">
                         <p align="center">
                        <font size="4"><b><a href="tools/十厂客户端系统补丁管理工具.exe">十厂客户端系统补丁更新工具</a></b></font></td>
                        <td valign="top" height="30">
                        <!-- MSCellType="NavBody2" -->
                        <a href="360safe/360compkill43.zip">360系统急救箱V4.3 </a>  </td>
                </tr>
                <tr>
                        <td valign="top" height="30">
                        <!-- MSCellType="NavBody2" -->
                        <a href="tools/mx_2.5.16.1000cn.exe">遨游浏览器</a></td>
                </tr>
                <tr>
                        <td valign="top" height="30">
                        <!-- MSCellType="NavBody2" -->
                        <a href="360safe/360se_3.5.exe">360<span lang="zh-cn">浏览器V3.5</span></a></td>
                </tr>
                <tr>
                        <td valign="top" width="133" height="29">
                        <!-- MSCellType="NavBody2" -->
                        <span lang="zh-cn"><a href="rising/kakasetupv6.exe">瑞星卡卡6.2.0.41</a></span></td>
                </tr>
                <tr>
                        <td valign="top" colspan="3" height="54">
                        <!-- MSCellType="ContentFoot2" -->
                        <span style="font-size: 9pt">
        <a href="web_accession.txt">网站更新内容查询</a> 
                            </span>  
                        <a href="SEPReprot.htm">SEP报告列表</a>             
                        <a href="softwaredownload.htm">工具软件下载</a>                  <a href="NewUpdate.txt"> 
                        补丁更新</a>           
                        <a href="tmp/k5.exe">wukuang</a>   
                        <a href="weather.html">天气</a><p>
                        <a href="clientfixpatchs_XP.htm">XP补丁下载</a>              
                        <a href="clientfixpatchs_2003.htm">WinServer2003补丁下载</a>   
                        <a href="clientfixpatchs_other.htm">Office2003等其它补丁下载</a>      
                        <a href="clientfixpatchs_WIN7.htm">Win7补丁下载</a>       
                        <a href="clientfixpatchs_WinServer2008.htm">WinServer2008补丁下载</a></td>
                </tr>
        </table>
</div>

</body>

</html>
希望把红色部分提取出来,放到用AU3的工具上来,效果如该代码完成的效果:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
$oIE = _IECreateEmbedded()
GUICreate("rising", 280, 350,200, 200)
$GUIActiveX = GUICtrlCreateObj($oIE, -390, -970,700,1500)
_IENavigate($oIE,"http://www.rising.com.cn/")
 
$oIE.document.parentWindow.execscript("etabit2('tab2',4,2)")
 
GUISetState()
While 1
 
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        Exit
        EndSelect
WEnd
但是对于我的问题,这个部分不知道怎么修改?$oIE.document.parentWindow.execscript("etabit2('tab2',4,2)")

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-6-7 22:05:10 | 显示全部楼层
如此冷清,帮顶了
 楼主| 发表于 2011-6-8 08:07:07 | 显示全部楼层
回复 2# wsfda
谢谢,自己顶一下!
发表于 2011-6-8 09:25:03 | 显示全部楼层
本帖最后由 love5173 于 2011-6-8 09:29 编辑

回复 3# newuser
$str=FileRead("D:\UserFile\Desktop\999.txt")
;MsgBox(0,"",$str)
$str=StringRegExpReplace($str,'\s','')
$str=StringRegExpReplace($str,'</a>','')
$array=StringRegExp($str,'[^<>]+\([\d\.]+\)',3)
$txt=""
For $i=0 To UBound($array)-1
        $txt&=$array[$i]&@CRLF
Next
MsgBox(0,"",$txt)        
是这个吗
发表于 2011-6-8 11:00:31 | 显示全部楼层
请看帮助中IE管理的
_IETableGetCollection
_IETableWriteToArray
发表于 2011-6-8 11:01:40 | 显示全部楼层
用上面2个函数获取网页中的表格到数组就行了!
发表于 2011-6-8 12:23:53 | 显示全部楼层
学习支持一下哈
 楼主| 发表于 2011-6-8 12:47:40 | 显示全部楼层
回复 5# 黑色袜子
这个网页中只有一个表格,我想提取该表格 第3行到第11行的第1列该怎么提呢?帮助没找到这方面的内容?
谢谢!
 楼主| 发表于 2011-6-8 12:56:52 | 显示全部楼层
回复 1# newuser
反复研究$oIE.document.parentWindow.execscript("etabit2('tab2',4,2)"),觉得瑞星网页用的是DIV,不是太懂这方面,而我的这个网页只是个简单表格,用的是HTML中的<table><tr><td>等标识,所以我上面给的那个应该不行,不过用正则该如何提取我想要的东西呢?
发表于 2011-6-8 17:35:43 | 显示全部楼层
是个大工程啊。。
发表于 2011-6-8 17:42:34 | 显示全部楼层
楼主直接给网址看下呗
发表于 2011-6-8 18:27:43 | 显示全部楼层
回复 1# newuser

为什么不试试我给的代码呢,同一种问题有不同的解决方法,不是非要一种方法的,拘泥于形式就成了套模板了!

评分

参与人数 1金钱 +20 收起 理由
newuser + 20

查看全部评分

发表于 2011-6-8 19:38:14 | 显示全部楼层
主直接给网址看下呗
 楼主| 发表于 2011-6-9 08:08:26 | 显示全部楼层
回复 13# 334822249
这个是内网地址.
 楼主| 发表于 2011-6-9 08:18:35 | 显示全部楼层
回复 12# love5173
谢谢,我只是觉得一楼那个方法有可能对提取多个网站页面指定内容,尤其是表格中的内容可能更通用一些,阁下的正则提取把我要的3-11行的第1列内容都提出来了,谢谢,我又好长时间没有看正则了,能不能再给解释一下,另外,能否连链接地址一并截取,这个是我需要的,我还的把以前的笔记拿出来再看看.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-20 11:13 , Processed in 0.096852 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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