手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp通用采集函数冗余版可以保存文件到本地
asp通用采集函数冗余版可以保存文件到本地
摘要:

<%

'名称:asp通用采集函数冗余版,要精品版的有心人自己改

'作者:柳永法

'日期:2007-6-23

FunctiongetHTTPPage(Path)

t=GetBody(Path)

getHTTPPage=BytesToBstr(t,"GB2312")

EndFunction

FunctionGetBody(url)

OnErrorResumeNext

Setxmlhttp=CreateObject("Microsoft.XMLHTTP")

Withxmlhttp

.Open"Get",url,False,"",""

.Send

.waitForResponse1000

GetBody=.ResponseBody

EndWith

Setxmlhttp=Nothing

EndFunction

FunctionBytesToBstr(Body,Cset)

OnErrorResumeNext

Dimobjstream

Setobjstream=Server.CreateObject("adodb.stream")

objstream.Type=1

objstream.Mode=3

objstream.Open

objstream.WriteBody

objstream.Position=0

objstream.Type=2

objstream.Charset=Cset

BytesToBstr=objstream.ReadText

objstream.Close

Setobjstream=Nothing

EndFunction

FunctiongetHTTPimg(url)

OnErrorResumeNext

Dimxmlhttp

Setxmlhttp=server.CreateObject("MSXML2.XMLHTTP")

xmlhttp.Open"GET",url,false

xmlhttp.send()

Ifxmlhttp.Status<>200ThenExitFunction

getHTTPimg=xmlhttp.responseBody

Setxmlhttp=Nothing

IfErr.Number<>0ThenErr.Clear

EndFunction

FunctionSave2Local(from,tofile)

Dimgeturl,objStream,imgs

geturl=Trim(from)

imgs=gethttpimg(geturl)

SetobjStream=Server.CreateObject("ADODB.Stream")

objStream.Type=1

objStream.Open

objstream.Writeimgs

objstream.SaveToFiletofile,2

objstream.Close()

Setobjstream=Nothing

EndFunction

%>

<%

NowDir=server.mappath("/")

CallSave2Local("http://www.baidu.com/img/logo.gif",NowDir&"baidulogo.gif")

CallSave2Local("http://flash.jninfo.net/images/banner.swf",NowDir&"banner.swf")

CallSave2Local("http://www.jb51.net.com/",NowDir&"jb51.htmll")

response.WritegetHTTPPage("http://www.jb51.net/")

%>

【asp通用采集函数冗余版可以保存文件到本地】相关文章:

通过数组给您的文件排序

用XML+FSO+JS实现服务器端文件的选择效果

asp取动态表单中数据并写入xml文件,用xsl显示

asp最常用的分页函数

用XML+FSO+JS实现服务器端文件的

用ASP写组件

图片自动保存到本地并利用aspjpeg为图片加水印

asp 防采集代码

FSO+递归生成文件列表(xml)

收集asp的常用函数

精品推荐
分类导航