asp采集常用的几个FUCTION(2)
作者:郁郁小蝎 来源:中国站长学院 时间:2007-09-05 19:45:00
5. function SaveData
作用 :保存文件,并自动创建多级文件夹
参数 :fromurl(远程文件地址),tofiles (保存位置)
Public Function SaveData(byref FromUrl,byref ToFiles)
ToFiles=trim(Replace(ToFiles,"//","/"))
flName=ToFiles
fldr=""
If IsExists(flName)=false then
GetNewsFold=split(flName,"/")
For i=0 to Ubound(GetNewsFold)-1
if fldr="" then
fldr=GetNewsFold(i)
else
fldr=fldr&"\"&GetNewsFold(i)
end if
If IsFolder(fldr)=false then
CreateFolder fldr
End if
Next
SaveFiles FromUrl,flName
End if
End function
6. function GetData
作用 :取得远程数据
参数 :url(远程文件地址),getmode (模式:0为二进制,1为中文编码)
Public Function GetData(byref url,byref GetMode)
’on error resume next
SourceCode = OXML.open ("GET",url,false)
OXML.send()
if OXML.readystate<>4 then exit function
if GetMode=0 then
GetData = OXML.responseBody
else
GetData = BytesToBstr(OXML.responseBody)
end if
if err.number<>0 then err.Clear
End Function
7. function FormatImgPath
作用 :格式化远程图片地址为本地位置
参数 :imgurl(远程图片地址),imgfolder (本地图片目录),fristname(加入的前缀名称)
Public Function FormatImgPath(byref ImgUrl,byref ImgFolder,byref FristName,byref noimg)
strpath=""
ImgUrl=ImgUrl
if instr(ImgUrl,"Nophoto") or lenb(GetData(ImgUrl,0))<=0 then
strpath=noimg
Response.Write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
else
if Instr(ImgUrl,".asp") then
strpath=FristName&"_"&Mid(ImgUrl, InStrRev(ImgUrl, "=")+1)&".jpg"
else
strpath=FristName&"_"&Mid(ImgUrl, InStrRev(ImgUrl, "/")+1)
end if
strpath = ImgFolder&"/"&strpath
strpath = Replace(strpath,"//","/")
if left(strpath,1)="/" then strpath=right(strpath,len(strpath)-1)
strpath = trim(strpath)
Response.Write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
savedata ImgUrl,strpath
end if
FormatImgPath = strpath
End function
相关阅读:
ASP中常用的22个FSO文件操作函数
标签:采集,function,asp
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
httpwatch 的页面元素加载时间表
2008-02-13 08:28:00
![](https://img.aspxhome.com/file/UploadPic/20082/13/200821383430675s.gif)
ASP常用函数:IsBlank()
2008-09-28 13:21:00
MySQL 数据(字段)类型
2011-09-10 16:15:56
为博客增加社会化分享按钮代码
2010-01-31 16:52:00
Javascript的一种模块模式
2007-12-05 14:04:00
JavaScript正则表达式的简单应用:高亮显示
2008-07-20 12:46:00
教你制作1px边框表格的四种方法
2008-10-04 10:16:00
学习ASP的理由 分析小结
2011-02-26 10:54:00
asp如何显示已在数据库编码了的相对应的记录?
2010-06-09 18:44:00
再谈动态添加样式规则
2009-09-02 13:10:00
Javascript 中对中文长度对行判断
2009-07-05 18:39:00
Oracle入侵常用操作命令整理
2009-03-04 11:11:00
Dreamweaver MX技巧之超链接
2009-05-29 18:40:00
![](https://img.aspxhome.com/file/UploadPic/20072/200723113349643s.jpg)
何在MySQL数据库中定义外键
2009-12-17 12:29:00
Oracle 8i在P4上的安装
2010-07-31 13:19:00
SQL指令植入式攻击的危害及其防范措施
2008-12-19 14:07:00
通用分页存储过程
2007-11-28 13:08:00
框架iframe子页面,自适应高度方法
2008-06-07 13:31:00
asp统计在线人数是实时的吗?
2010-07-14 21:07:00
超酷的js图片轮播渐变效果
2007-10-10 20:45:00
![](https://img.aspxhome.com/file/UploadPic/200710/10/2007101021445381s.jpg)