当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp通用采集函数冗余版可以保存文件到本地

ASP
超级ASP版DataGrid:SkyGrid本地下载
用QuickWAP组件结合ASP建设Wap站点
ASP中取得图片宽度和高度的类(无组件)
在ASP处理程序时显示进度
结合FSO操作和Aspjpeg组件写的Class
asp实现的7xi音乐网的采集源代码
用asp+xmlhttp编写web采集程序
推荐ASP超速入门视频教程
关于“未指定的错误”的问题 的比较正解的解决方法
用asp脚本实现限制IP访问
aspupload 3.0 下载与使用集锦
[教程+分享]具有良好体验度的Web注册系统
asp 实现视频显示的效果函数
asp实现图片右键滑轮控制大小的函数
彻底掌握ASP分页技术杂谈
aspupload文件重命名及上传进度条的解决方法附代码
ASPJPEG综合操作的CLASS类
asp通用采集函数冗余版可以保存文件到本地
使用ODBC数据库管理Serv-U的FTP用户及相关ASP编程[附源码示例下载]
[asp]阿里西西的alexa采集效果代码

ASP 中的 asp通用采集函数冗余版可以保存文件到本地


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 73 ::
收藏到网摘: n/a

<%
'名称:asp通用采集函数冗余版,要精品版的有心人自己改
'作者:柳永法
'日期:2007-6-23
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage = BytesToBstr(t, "GB2312")
End Function
Function GetBody(url)
On Error Resume Next
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
With xmlhttp
.Open "Get", url, False, "", ""
.Send
.waitForResponse 1000
GetBody = .ResponseBody
End With
Set xmlhttp = Nothing
End Function
Function BytesToBstr(Body, Cset)
On Error Resume Next
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 getHTTPimg(url)
On Error Resume Next
Dim xmlhttp
Set xmlhttp = server.CreateObject("MSXML2.XMLHTTP")
xmlhttp.Open "GET", url, false
xmlhttp.send()
If xmlhttp.Status<>200 Then Exit Function
getHTTPimg = xmlhttp.responseBody
Set xmlhttp = Nothing
If Err.Number<>0 Then Err.Clear
End Function
Function Save2Local(from, tofile)
Dim geturl, objStream, imgs
geturl = Trim(from)
imgs = gethttpimg(geturl)
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objstream.Write imgs
objstream.SaveToFile tofile, 2
objstream.Close()
Set objstream = Nothing
End Function
%>
<%
NowDir = server.mappath("/")
Call Save2Local("http://www.baidu.com/img/logo.gif", NowDir & "/upload/tech/20091012/20091012012331_00ec53c4682d36f5c4359f4ae7bd7ba1.gif")
Call Save2Local("http://flash.jninfo.net/images//upload/tech/20091012/20091012012331_9232fe81225bcaef853ae32870a2b0fe.swf", NowDir & "/upload/tech/20091012/20091012012331_9232fe81225bcaef853ae32870a2b0fe.swf")
Call Save2Local("http://www.ruanchen.com.com/", NowDir & "jb51.htmll")
response.Write getHTTPPage("http://www.ruanchen.com/")
%>