注册 登录
编程论坛 ASP技术论坛

关于asp转html的代码 问题 在本地可以运行 在服务器上为什么不行 没反应

guang2356447 发布于 2010-05-28 01:11, 499 次点击
以下是我的代码    在本地测试可以    在服务器上为什么生成不了
谁有更好的代码没有啊   给份   多谢
<%
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://www.'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的页面地址
dizhi=server.MapPath("jt/index.html")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If

Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
crfi.close
fs.close
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>更新完成!</font>"
%>
1 回复
#2
gupiao1752010-05-28 09:23
<%
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")
其他代码我不知道,但是就字面上看你饭了一个很致命的错误!
看红色代码,下面知道加server,为什么上面却没有加,服务端必须加server的,上下都应该用:set objstream = Server.CreateObject("adodb.stream")
1