回 帖 发 新 帖 刷新版面

主题:[求助]生成静态页

下面这种方法为什么不能生成呢。希望大家帮忙看一下,谢谢了。
<%
Function GetPage(url) 
'获得文件内容
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP") 
With Retrieval 
  .Open "Get", url, False ', "", "" 
  .Send 
  GetPage = BytesToBstr(.ResponseBody)
End With 
Set Retrieval = Nothing 
End Function
Function BytesToBstr(body)
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 = "GB2312"
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function
on error resume next
Url="http://localhost/fs.asp"'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)
'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'要存放的页面地址
dizhi=server.MapPath("fs.htm")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If
Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>更新完成!</font>"
%>

回复列表 (共1个回复)

沙发

试试这个:
<%
set http=server.createobject("Microsoft.XMLHTTP")
http.open "GET","http://pcfun.cn:888/freehost.asp",false
http.send()
if http.readystate=4 then
    set adoStream = Server.CreateObject("adodb.stream") 
    adoStream.Type = 1 
    adoStream.Mode =3 
    adoStream.Open 
    adoStream.Write http.responseBody
    adoStream.Position = 0 
    adoStream.Type = 2 
    adoStream.Charset = "GB2312" 
    adoStream.savetofile "pcfun.htm",2
    adoStream.Close
    set adoStream = nothing
end if
set http=nothing 
%>

我来回复

您尚未登录,请登录后再回复。点此登录或注册