想通过VBS获取指定网页中的文本,例如时间、天气等元素。

例如获取http://open.baidu.com/special/time/网页中的北京时间,用msgbox输出
2026年09月20日 00:55
有2个网友回答
网友(1):

URL = "https://gss0.baidu.com/8aQDcnSm2Q5IlBGlnYG/special/time"
set ie = CreateObject("InternetExplorer.Application")
ie.Navigate URL
ie.Refresh
while ie.Busy OR ie.ReadyState <> 4
wend
msgbox "北京时间:" & ie.document.getElementById("time").innerHTML
ie.Quit
将上面的代码保存成【.VBS】结尾的文件,若有空白行,删除空白行,然后双击运行就可以了。

网友(2):

Const ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
fso.CreateFolder("help")
Set tf = fso.OpenTextFile("a.txt",1)
Do while tf.AtEndOfStream = false

fso.CopyFile Trim(Split(tf.readline,":")(1)) , ".\help\"
loop
tf.close