|

楼主 |
发表于 2005-11-18 11:37:06
|
来自 中国广东深圳
晕,太长发不完整,继续发
- '建立数据库连接
- Set conn = CreateObject("ADODB.Connection")
- DSNtemp = "DRIVER={SQL Server};SERVER=127.0.0.1;UID=sa;PWD=123456;DATABASE=datebase"
- conn.open DSNtemp
- sql = "select * from pic where fromSite='网易' and localPath is null order by id"
- set rs = CreateObject("Adodb.recordset")
- rs.open sql,conn,1,3
- do while not rs.eof
- url = rs("url")
- if left(url,1) = "/" then url = right(url,len(url)-1)
- urlArr = split(url,"/")
- urlPathNum = ubound(urlArr) - 1 '有几级目录
- localPath = ""
- '第一种文件名命名方法,适用于一套图片放一个目录
- for i = 0 to urlPathNum
- localPath = localPath & "" & urlArr(i)
- next
- fileName = urlArr(urlPathNum + 1) '文件名
- 'filePath = savePath & localPath '新路径
- 'fileExcArr = split(urlArr(urlPathNum + 1),".") 'fileExcArr(ubound(fileExcArr))=扩展名
- '第二种文件名命名方法,适用于多套图片放同一目录,如a_01 a_02 b_01 b_02
- 'for i = 0 to urlPathNum - 1
- ' localPath = localPath & "" & urlArr(i)
- 'next
- 'fileExcArr = split(urlArr(urlPathNum + 1),".")
- 'fileName = urlArr(urlPathNum) & "." & fileExcArr(1) '新文件名
- 'filePath = savePath & localPath '新路径
- 'msgbox("Path: " & filePath & chr(13) & "Name: " & fileName & "")
- 'msgbox("url: " & down_head & url_old & chr(13) & "local: " & filePath & "" & fileName & "")
- down = False
- downSizeStatus = ""
- for s = 0 to Ubound(imageSiezArr)
- downUrl = down_head & "/" & replace(url,"128x128",imageSiezArr(s))
- fileStream = GetBody(downUrl)
- if len(fileStream) > 0 then
- fileNameTemp = split(fileName,".")
- fileName = imageSiezArr(s) & "." & fileNameTemp(ubound(fileNameTemp))
- if not down then
- localSavePath = savePath & "" & imageSiezArr(s) & localPath
- CreateDIR localSavePath
- down = SaveToFile(fileStream , localSavePath & "" & fileName) '返回True则下载成功
- imageMaxSize = imageSiezArr(s)
- end if
- downSizeStatus = downSizeStatus & "1,"
- else
- downSizeStatus = downSizeStatus & "0,"
- end if
- next
- if down then
- imageMaxSizeTemp = split(imageMaxSize , "x")
- imageWidth = imageMaxSizeTemp (0)
- imageHeight = imageMaxSizeTemp (1)
- rs("localPath") = localPath
- rs("localName") = fileName
- rs("maxWidth") = imageWidth
- rs("maxHeight") = imageHeight
- rs("downSizeStatus") = left(downSizeStatus , len(downSizeStatus)-1)
- rs("downtime") = now()
- rs.update
- end if
- rs.movenext
- loop
- rs.close
- set rs = Nothing
- msgBox("下载完成!")
- End Sub
复制代码 |
|