找回密码
 加入
搜索
查看: 2045|回复: 3

[AU3基础] [已解决]获取网页源码的问题?

[复制链接]
发表于 2011-6-3 10:41:36 | 显示全部楼层 |阅读模式
本帖最后由 newuser 于 2011-6-3 11:12 编辑

#include <INet.au3>
$s_URL='http://www.soso.com/tb.q'
$soure = _INetGetSource($s_URL, 0)
Msgbox(0, 0, BinaryToString($soure, 4))
用以上代码获取不到如下的效果,汉字部分都没有,因为我想把今天、明天、后天的温度、风级和天气状况截取到INI或TXT文件中提供给不能访问因特网的用户:
<today>
<temperature><![CDATA[13℃~19℃]]></temperature>
<weather><![CDATA[中雨]]></weather>
<wind><![CDATA[东南风3-4级]]></wind>
</today>
<tomorrow>
<temperature><![CDATA[14℃~24℃]]></temperature>
<weather><![CDATA[多云]]></weather>
<wind><![CDATA[北风3-4级]]></wind>
</tomorrow>
<thirdDate>
<temperature><![CDATA[15℃~27℃]]></temperature>
<weather><![CDATA[晴]]></weather>
<wind><![CDATA[西北风3-4级]]></wind>
</thirdDate>
发表于 2011-6-3 11:03:14 | 显示全部楼层
多注意点基本函数,别只顾着集成的函数.
;使用InetGet
InetGet("http://www.soso.com/tb.q", @TempDir & "\1.xml", 1)
MsgBox(0, "Result", FileRead(@TempDir & "\1.xml"))
Exit


;使用_IEDocReadHTML
#include <IE.au3>
Local $oIE = _IECreate("http://www.soso.com/tb.q")
MsgBox(0, "Result", _IEDocReadHTML($oIE))
Exit


;直接使用HTML DOM对象
#include <IE.au3>
Local $oIE = _IECreate("http://www.soso.com/tb.q")
MsgBox(0, "Result", $oIE.document.getElementsByTagName("xml").item(0).outerHTML)
Exit
 楼主| 发表于 2011-6-3 11:09:40 | 显示全部楼层
回复 2# easefull
呵呵,谢谢!
发表于 2011-8-11 17:28:38 | 显示全部楼层
好东西,学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 12:53 , Processed in 0.076756 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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