从互联网上的路径获取文件列表 [英] get list of files from path on the internet

查看:111
本文介绍了从互联网上的路径获取文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i' m自动化一个项目,每个月我需要去一个网站并从那里复制文件。
我可以复制文件,问题在于它们的命名如下,所以我无法知道该月要复制哪个文件。

i'm automating a project where every month i need to go on a website and copy a file from there. i'm able to copy the file, the problem is that they're named like below so there's no way for me to know which file to copy that month.

filename2015011023549.zip

filename2015011023549.zip

filename2015021922876.zip

filename2015021922876.zip

是否可以从中获取文件列表一个网站?

is there a way to get a list of files from a website?

推荐答案

将包含文件列表的页面下载到本地文件,然后解析该文件以获取可能的文件名候选:

You download the page (see in-line comments) with the file listing to a local file, then parse that file for possible file name candidates:

Option Compare Database
Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
    ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) _
    As Long

Public Function DownloadFile( _
    ByVal strURL As String, _
    ByVal strLocalFilename As String) _
    As Long

' Download file or page with public access from the web.
' 2004-12-17. Cactus Data ApS, CPH.

' Usage, download a file:
' lngRet = DownloadFile("http://www.databaseadvisors.com/Graphics/conf2002/2002ConferencePicsbySmolin/images/dba02smolin27.jpg", "c:\happybassett.jpg")
'
' Usage, download a page:
' lngRet = DownloadFile("http://www.databaseadvisors.com/conf2002/conf200202.asp", "c:\dbaconference.htm")

' Returns 0 if success, error code if not.
' Error codes:
' -2146697210 "file not found".
' -2146697211 "domain not found".

' Limitation.
' Does not check if local file was created successfully.

    Dim lngRetVal As Long

    lngRetVal = URLDownloadToFile(0, strURL & vbNullChar, strLocalFilename & vbNullChar, 0, 0)

    DownloadFile = lngRetVal

End Function

这篇关于从互联网上的路径获取文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆