'获取网页HTML内容
Function GetHtmlCode(url)
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
GetHtmlCode=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
End function
'编码转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.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
'写文件
Function WriteHtml(htmlcode,htmlname)
Dim fpath,fname,fso,fout
fname=htmlname '要生成的文件名
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.Createtextfile(server.mappath(fname),true)
fout.writeline htmlcode '文件内容
fout.close
set fout=nothing
set fso=nothing
WriteHtml="写文件:" & server.mappath(htmlname) & " 成功"
End Function