28,390
社区成员
发帖
与我相关
我的任务
分享
Dim Html
dim Url
Url="http://www.***.com/c.asp"
Html = getHTTPPage(Url)
Writefile "D:\wwwroot\index.htm",Html,"UTF-8"
'获取某个地址的html代码
'url:网页地址
Function getHTTPPage(Url)
Dim Http
Set Http=createobject("MSXML2.XMLHTTP")
Http.open "GET",Url,False
Http.send()
If Http.readystate <> 4 Then
Exit Function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")
Set http = Nothing
If err.number <> 0 Then err.Clear
End Function
Function BytesToBstr(body,Cset)
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
'保存文件
'fileurl:要保存到的地址
'WriteHtml:要保存的内容
Function Writefile(fileurl,WriteHtml,Cset)
Set o_strm = CreateObject("ADODB.Stream")
With o_strm
.Type = 2
.Open
.Charset = Cset
.Position = o_strm.Size
.WriteText = WriteHtml
.SaveToFile fileurl,2
.Close
End With
Set o_strm = Nothing
End Function