让人崩溃的正则表达式
<div class="weatherwapper"><div class="left_content">
<div class="box_contentl">
<h2 class="tit01_contentl" >
<span style="text-align:center; margin-top: 3px"><select onchange="MM_jumpMenu('parent',this,0)">
<option>相关地区</option>
<option value="/html/weather/101010100.shtml">北京</option>
<option value="/html/weather/101010300.shtml">朝阳</option>
<option value="/html/weather/101010400.shtml">顺义</option>
<option value="/html/weather/101010500.shtml">怀柔</option>
<option value="/html/weather/101010600.shtml">通州</option>
<option value="/html/weather/101010700.shtml">昌平</option>
<option value="/html/weather/101010800.shtml">延庆</option>
<option value="/html/weather/101010900.shtml">丰台</option>
<option value="/html/weather/101011000.shtml">石景山</option>
<option value="/html/weather/101011100.shtml">大兴</option>
<option value="/html/weather/101011200.shtml">房山</option>
<option value="/html/weather/101011300.shtml">密云</option>
<option value="/html/weather/101011400.shtml">门头沟</option>
<option value="/html/weather/101011500.shtml">平谷</option>
<option value="/html/weather/101011600.shtml">八达岭</option>
<option value="/html/weather/101011700.shtml">佛爷顶</option>
<option value="/html/weather/101011800.shtml">汤河口</option>
<option value="/html/weather/101011900.shtml">密云上甸子</option>
<option value="/html/weather/101012000.shtml">斋堂</option>
<option value="/html/weather/101012100.shtml">霞云岭</option>
<option value="/html/weather/101010200.shtml">海淀</option>
</select></span>
今天是2008年12月29日 星期一 十二月初三 <span class="f888"></span> <span class="f777"></span>
</script>
</h2>
<div class="left_contenttopl">
<h3><strong>通州</strong>(Tongzhou)</h3>
<a href="http://club.weather.com.cn/thread-1708-1-1.html" target="_blank"><p><img src="/m/i/city/101010600m.jpg" alt=""width="180" height="146"/></p></a>
<h4><span><em><a href="http://club.weather.com.cn/thread-1708-1-1.html" target="_blank">城市标识图片征集</a></em></span><span><em><a href="http://club.weather.com.cn/" target="_blank">天气社区</a></em></span></h4>
</div>
<script language="javaScript" type="text/javascript" src="../../m/j/sk.js" /> </script>
<div class="right_contenttopl">
<h3>相关数据</h3>
<dl>
<dt>日出时间</dt>
<dd>2008-12-29 07:34:24</a></dd>
<dt>日落时间</dt>
<dd>2008-12-29 16:58:52</a></dd>
<dt>邮政编码</dt>
<dd><strong><a><a><a><a>101100</a></a></a></a></strong></dd>
</dl>
</div>
</div>
<div class="box_contentwea">
<div class="box_contenttoday210">
<h2>
<em class="menu_01 on" id="m_1_1"><a href="#"onclick="javascript:menu(1,1)">今日天气预报 (08:00发布)</a></em>
<em class="menu_02" id="m_1_2"><a href="#" onclick="javascript:menu(1,2)">生活指数</a></em>
<em class="menu_03" id="m_1_3"><a href="#" onclick="javascript:menu(1,3)">健康指数</a></em>
<em class="menu_04" id="m_1_4"><a href="#" onclick="javascript:menu(1,4)">交通指数</a></em>
<em class="menu_05" id="m_1_5"><a href="#" onclick="javascript:menu(1,5)">户外指数</a></em>
</h2>
<div class="box_contenttodayinwea" id="c_1_1">
<p>
<span><a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank"><img src="/m/i/icon_weather/42x30/d00.gif" /></a> <a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank"><img src="/m/i/icon_weather/42x30/n00.gif" /></a></span>
<em><strong>晴</strong></em>
<em class="no_today">0℃/ -8℃</em>
<em>北风4-5级转微风</em><br/>
</p>
<dl class="right">
<dd><span>紫外线:弱<br />
洗车:较适宜<br />
<img src="/m/i/twc/up.gif" /></span><em>气温趋势</em></dd>
<dd><span><br />
<br />
<img src="/m/i/twc/wind2.gif" /></span><em>今日风力</em></dd>
<dd><span>穿衣:寒冷<br />
舒适度:较不舒适<br />
<img src="/m/i/twc/co2.gif" /></span><em>舒适指数</em></dd>
<dt><span></span></dt>
</dl>
</div>
<div class="box_contenttodayinwea" id="c_1_2" style="display: none;">
<dl class="two">
<dt><img src="/m/i/indexer/ct_s.gif" /></dt>
<dd><strong>穿衣指数:<i class="no1_weather">寒冷</i></strong><br />天气寒冷,建议着厚羽绒服、毛皮大衣加厚毛衣等隆冬服装。年老体弱者尤其要注意保暖防冻。</dd>
</dl>
<dl class="two">
我看了三天多的正则表达式,但还是不行。上次关于正则表达式的问题,三恨和BOB帮我写了代码,很轻松搞定,现在我想把“天气”,“温度”“风力”“紫外线”提取出来,然后我自己就想写,代码是这样的:
#include <INet.au3>
$oIE=_INetGetSource("http://www.weather.com.cn/html/weather/101010600.shtml")
$sReturn=StringRegExp($oIE,"<(?i)em><strong>(.*?)</(?i)strong>",1);提取出天气代码
msgbos=(64,"test",$sReturn)
用MSGBOX测试的时候,有时候是0,有时候是1,为什么呢?请各路高手帮我写一下!
[ 本帖最后由 abcabc8759 于 2009-1-3 09:11 编辑 ] #include <INet.au3>
$oIE=_INetGetSource("http://www.weather.com.cn/html/weather/101010600.shtml")
$sReturn=StringRegExp($oIE,"<(?i)em><strong>(.*?)</(?i)strong>",1);提取出天气代码
msgbos=(64,"test",$sReturn) #include <INet.au3>
$oIE=_INetGetSource("http://www.weather.com.cn/html/weather/101010600.shtml")
$sReturn=StringRegExp($oIE,"<(?i)em><strong>(.*?)</(?i)strong>",1);提取出天气代码
msgbox=(64,"test",$sReturn)
不能运行啊!再帮我看看一下啊!
>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\80G桌面\tq.au3"
D:\80G??\tq.au3 (4) : ==> Missing separator character after keyword.:
MsgBox=(64,"test",$sReturn)
MsgBox^ ERROR
>Exit code: 1 Time: 0.310 我在顶顶哦! 我对 正则表达式也同样的崩溃!:face (1): Dim $var = FileRead("a.txt"), $s
$str = stringRegExp($var, ">([^>]+)<(?:/|br)", 3)
For $d = 0 to Ubound($str) - 1
$s &= $str[$d] & @crLf
Next
msgbox(0, '', $s) 不知道是我测试出问题了还是怎么了,各路高手的代码,我一直测试不通啊· $oIE=_INetGetSource("http://www.weather.com.cn/html/weather/101010600.shtml")
下载了乱码,先把这问题搞好,你搜索一下论坛吧 OK,已经搞定了乱码,没乱码问题,正则表达式就好了!
页:
[1]