asp转HTML,自己写了几个函数,之后的不知道怎么写了,望高人指教!!

zhenai0512 2008-06-12 10:38:37
只要思想,就是远程获取ASP首页,递归取出超连接地址,之后字符串替换,创建静态页。下面是自己写的几个函数,之后的程序不知道怎么写了,请高手指教:小弟谢了!
<%
'要读取的首页
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
on error resume next
Url="http://www.usadaxue.cn/web0836/shownew.asp?id=50" '要读取的网站首页
wstr = GetPage(Url)
%>
<%
'把读取的网页内容写入文件
Function BytesToBstr(from tofile)
dim objstream geturl body
geturl=trim(from) 'Trim 函数可删除字符串两侧的空格
body=GetPage(geturl) '取得具休内容的过程
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1 '以二进制模式打开
objstream.Open
body = replace(body,"http://www.usadaxue.cn/web0836/shownew.asp?id={id}","http://www.usadaxue.cn/web0836/shownew_{id}.htm")
objstream.Write body '将字符串内容写入缓冲
objstream.Charset = "GB2312"
objstream.SaveToFile server.mappath(tofile),2 '把读取的网页内容写入文件
objstream.Close
set objstream = nothing
End Function
'response.write(wstr)
%>
<%
function getimgs(str)
getimgs=""
Set objRegExp1 = New Regexp '设置配置对象
objRegExp1.IgnoreCase = True '忽略大小写
objRegExp1.Global = True '设置为全文搜索
objRegExp1.Pattern = "http://.+?""" '取出里面的超连接
end function
%>

<%
'创建静态页文件
Set fs=Server.CreateObject("Scripting.FileSystemObject")
dizhi=server.MapPath("000.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>"
%>
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhenai0512 2008-06-12
  • 打赏
  • 举报
回复
自己顶下,急啊!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧