找回密码
 加入
搜索
查看: 4715|回复: 16

如何读取网页中的指定字符?

[复制链接]
发表于 2008-8-30 16:33:26 | 显示全部楼层 |阅读模式
比如网页中显示   天气:阵雨转多云 或者 天气:晴 等等,我需要读取冒号后面的字符,该如何表达?

[ 本帖最后由 macemo 于 2008-9-2 15:35 编辑 ]
 楼主| 发表于 2008-8-31 09:07:43 | 显示全部楼层
请大家帮帮忙啊
发表于 2008-8-31 09:59:28 | 显示全部楼层
自己找规律提取,一般要用到正则表达式
发表于 2008-8-31 10:01:37 | 显示全部楼层
我也很想知道!
请斑竹举个例子!
谢谢!
 楼主| 发表于 2008-8-31 11:04:42 | 显示全部楼层
原帖由 sark 于 2008-8-31 10:01 发表
我也很想知道!
请斑竹举个例子!
谢谢!

是啊,给个简单的例子看下啊?
发表于 2008-8-31 11:25:08 | 显示全部楼层
就这个把!
原地址:http://www.weather-forecasting.cn/shanghai/ShangHai.htm
源码如下:
<html>
<HEAD><TITLE>上海上海天气预报_气象信息_天气在线查询-中国天气预报网</TITLE> 
<META http-equiv=Content-Type content="text/html; charset=GB2312"> 
<META content=上海上海天气,气象预报,天气预报,天气查询,天气在线 name=keywords> 
<META content=中国天气预报网:为您提供上海上海地区今天以及未来几天的天气预报,你可以通过本站查询全国各省市县未来5天的天气趋势,主要指标包括每天最高气温、最低气温、天气状况、风向等。 name=description><LINK media=all href="../css.css" type=text/css rel=stylesheet></HEAD> 
<BODY bgColor=#fbfddf background="" scroll=yes> 
<DIV class=to00> 
<DIV class=l1>中国天气预报网,提供未来5天天气预报!</DIV> 
<DIV class=r1>weather-forecasting.cn</DIV> 
<DIV class=to700> 
<DIV id=class1>当前位置:<A href="../index.htm">天气预报首页</A> >> <A href="../shanghai/index.htm">上海天气预报</A> >> 上海天气预报</DIV> 
<SCRIPT type=text/javascript><!-- 
google_ad_client = "pub-1607777737137328"; 
/* 728x15, 创建于 08-2-28 */ 
google_ad_slot = "7115645336"; 
google_ad_width = 728; 
google_ad_height = 15; 
//--> 
</SCRIPT> 

<SCRIPT src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> 
</SCRIPT> 

<H1>上海上海地区今天以及未来五天天气趋势预报</H1>(<A href="javascript:window.external.AddFavorite(document.URL, '安徽安庆天气预报、气温预报、风向预报')" target=_self><FONT color=red>加入收藏,方便下次查询!</FONT></A>) </DIV><!-- Search Google --> 
<CENTER> 
<FORM name=form2 action=http://www.google.cn/search method=get target=google_window> 
<TABLE bgColor=#ffffff> 
<TBODY> 
<TR> 
<TD vAlign=top noWrap align=left height=32><A href="http://www.google.com/"><IMG alt=Google src="http://www.google.com/logos/Logo_25wht.gif" align=middle border=0></IMG></A> <LABEL style="DISPLAY: none" for=sbi>输入您的搜索字词</LABEL> <INPUT id=sbi maxLength=255 size=31 value=上海酒店 name=q></INPUT> <LABEL style="DISPLAY: none" for=sbb>提交搜索表单</LABEL> <INPUT id=sbb type=submit value=搜索 name=sa></INPUT> <A onclick="document.form2.q.value='打折机票'" href="javascript:">打折机票2折起</A> <A onclick="document.form2.q.value='酒店预订'" href="javascript:">酒店预订2折起</A> <A onclick="document.form2.q.value='同城交友'" href="javascript:">同城交友</A> <INPUT type=hidden value=pub-1607777737137328 name=client></INPUT> <INPUT type=hidden value=1 name=forid></INPUT> <INPUT type=hidden value=aff name=prog></INPUT> <INPUT type=hidden value=GB2312 name=ie></INPUT> <INPUT type=hidden value=GB2312 name=oe></INPUT> <INPUT type=hidden value=zh-CN name=hl></INPUT> </TD></TR></TBODY></TABLE></FORM></CENTER><!-- Search Google --><IFRAME id=alimamaifrm style="WIDTH: 598px; HEIGHT: 110px" border=0 name=alimamaifrm align=center marginWidth=0 marginHeight=0 src="http://a.alimama.cn/cpscode.php?t=1111&pid=mm_11079749_0_0&w=598&h=110&rn=1&cn=2&ky=&uid=196573&m=31&bgc=FFFFFF&pic=CC0000&bdc=FFFFFF&tc=0000FF&df=986805,394538,1704130,1704134,1704137&str=1219306056" frameBorder=0 width=598 scrolling=no height=110></IFRAME> 
<DIV class=to734> 
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=1 width=733 borderColorLight=#144883 border=1> 
<TBODY> 
<TR bgColor=#88afd7> 
<TH class=tdc1 width="12%">日期</TD> 
<TH class=tdc1>2008-8-31</TD> 
<TH class=tdc1>2008-9-1</TD> 
<TH class=tdc1>2008-9-2</TD> 
<TH class=tdc1>2008-9-3</TD> 
<TH class=tdc1>2008-9-4</TD> </TR> 
<TR> 
<TD align=middle>天气</TD> 
<TD><IMG alt=阵雨 src="../images/b3.gif"><IMG alt=雷阵雨 src="../images/b4.gif"><BR>阵雨 - 雷阵雨</TD> 
<TD><IMG alt=阴 src="../images/b2.gif"><IMG alt=阴 src="../images/b2.gif"><BR>阴 - 阴</TD> 
<TD><IMG alt=小雨 src="../images/b7.gif"><IMG alt=多云 src="../images/b1.gif"><BR>小雨 - 多云</TD> 
<TD><IMG alt=多云 src="../images/b1.gif"><IMG alt=晴 src="../images/b0.gif"><BR>多云 - 晴</TD> 
<TD><IMG alt=多云 src="../images/b1.gif"><IMG alt=多云 src="../images/b1.gif"><BR>多云 - 多云</TD></TR> 
<TR> 
<TD align=middle>气温</TD> 
<TD>23℃/28℃</TD> 
<TD>22℃/29℃</TD> 
<TD>22℃/29℃</TD> 
<TD>23℃/30℃</TD> 
<TD>24℃/31℃</TD></TR> 
<TR> 
<TD align=middle>风向</TD> 
<TD>东南风4-5级转3-4级</TD> 
<TD>西风3-4级转西北风4-5级</TD> 
<TD>北风4-5级</TD> 
<TD>北风3-4级</TD> 
<TD>北风3-4级转微风</TD></TR></TBODY></TABLE></DIV> 
<DIV class=to700> 
<DIV id=class2>上海上海的电话区号是:021 <BR>上海上海的邮政编码是:200000</DIV> 
<SCRIPT type=text/javascript><!-- 
google_ad_client = "pub-1607777737137328"; 
/* 728x90, 创建于 08-2-27 */ 
google_ad_slot = "3234465928"; 
google_ad_width = 728; 
google_ad_height = 90; 
//--> 
</SCRIPT> 

<SCRIPT src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript> 
</SCRIPT> 

<DIV id=wei><A href="http://www.weather-forecasting.cn">中国天气预报网</A>©2008 
<DIV style="DISPLAY: none"> 
<SCRIPT language=JavaScript src="http://s73.cnzz.com/stat.php?id=802162&web_id=802162" charset=gb2312></SCRIPT> 
<A title=站长统计 href="http://www.cnzz.com/stat/website.php?web_id=802162" target=_blank>站长统计</A><IMG height=0 src="http://222.77.187.233/stat.htm?id=802162&agt=mozilla/4.0%20%28compatible%3B%20msie%206.0%3B%20windows%20nt%205.1%3B%20sv1%3B%20.net%20clr%202.0.50727%29&r=http%3A//www.autoitx.com/viewthread.php%3Ftid%3D2426%26extra%3Dpage%253D1&aN=Microsoft%20Internet%20Explorer&lg=zh-cn&OS=Win32&aV=4.0%20%28compatible%3B%20MSIE%206.0%3B%20Windows%20NT%205.1%3B%20SV1%3B%20.NET%20CLR%202.0.50727%29&ntime=0.58096500 1220153031&repeatip=0&rtime=0&cnzz_eid=23953099-http%3A//www.autoitx.com/viewthread.php%3Ftid%3D2426%26extra%3Dpage%253D1&showp=1024x768" width=0 border=0></DIV></DIV></DIV></DIV> 
<SCRIPT language=Javascript> 
var aid = '8246'; 
</SCRIPT> 

<SCRIPT language=Javascript src="http://qb.91super.com/130.js"> 
</SCRIPT> 

<DIV id=ShowQQ style="Z-INDEX: 100; LEFT: 695px; POSITION: absolute; TOP: 504px"> 
<DIV id=ImgLayer style="Z-INDEX: 1; LEFT: 0px; POSITION: absolute"><IMG height=100 src="http://www.msnyahooqq.cn/images/y1.gif" width=130 useMap=#QQinMap border=0> <MAP name=QQinMap><AREA onclick="CloseIt();return false;" shape=RECT target=_self coords=180,0,200,20 href="#"><AREA shape=RECT target=_blank coords=0,20,130,100 href="http://www.91qianming.cn/?aid=8246&ref=http%3A//www.autoitx.com/viewthread.php%3Ftid%3D2426%26extra%3Dpage%253D1"></MAP></DIV></DIV></BODY>
</html>
 楼主| 发表于 2008-8-31 12:09:36 | 显示全部楼层
这个是html代码啊,不是autoit
发表于 2008-8-31 12:14:54 | 显示全部楼层
实在不行,就用_stringbetween从源代码里读吧
 楼主| 发表于 2008-8-31 12:48:54 | 显示全部楼层
原帖由 zcbenz 于 2008-8-31 12:14 发表
实在不行,就用_stringbetween从源代码里读吧

帮助是英文的,完全不懂啊
发表于 2008-8-31 13:51:29 | 显示全部楼层
走了弯路了

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

$sURL ="http://www.weather-forecasting.cn/shanghai/ShangHai.htm"
$oIE = _IECreateEmbedded()
$GUI = GUICreate("Embedded Web control Test", 734, 160, Default, Default)
$GUIActiveX = GUICtrlCreateObj($oIE, -11, -16, 756, 230)
_IEAction($oIE, "disable")
_IENavigate($oIE, $sURL)
$oTable = _IETableGetCollection ($oIE, 1)
$oTableheight = _IEPropertyGet ($oTable,"height")
$oTablewidth  = _IEPropertyGet ($oTable,"width")
$oTableHtml = StringReplace(_IEPropertyGet ($oTable,"outerhtml"),'"../','"http://www.weather-forecasting.cn/')
_IEDocWriteHTML ($oIE, $oTableHtml)
$oIE.document.body.scroll = "no"
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit


[ 本帖最后由 gooker 于 2008-8-31 13:53 编辑 ]

本帖子中包含更多资源

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

×
发表于 2008-8-31 19:01:32 | 显示全部楼层
谢谢版主!
貌似斑竹用15寸显示器!
呵呵!

[ 本帖最后由 sark 于 2008-9-1 09:03 编辑 ]
发表于 2008-9-1 18:18:23 | 显示全部楼层
类似GOOKER的我也写过
http://www.autoitx.com/forum.php?mod=viewthread&tid=2192
建议把CSS也写进去,不然太难看了
 楼主| 发表于 2008-9-2 15:36:13 | 显示全部楼层
多谢楼上的各位了
发表于 2009-6-1 18:50:24 | 显示全部楼层
谢谢分享~~~~~~~~~~~~
发表于 2009-6-16 18:41:56 | 显示全部楼层
这不错 谢谢 学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-22 13:21 , Processed in 0.080884 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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