【问题标题】:how to prevent cached response from MSXML2.XMLHTTP, vbscript如何防止来自 MSXML2.XMLHTTP、vbscript 的缓存响应
【发布时间】:2018-04-20 15:36:36
【问题描述】:

我正在 Windows 7 中使用 vbscript 编写 wscript。 该脚本需要从一个打开的 ftp 服务器中抓取一个文件,所以我必须使用 MSXML2.XMLHTTP 对象

我正在抓取的文件正在缓存在 C:\Users\user\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5

缓存的文件没有“过期”值,尝试使用 setRequestHeader 方法设置值似乎没有任何效果。

如果其他人需要此解决方案,我将自行回​​答

【问题讨论】:

    标签: vbscript windows-7 cache-control msxml2


    【解决方案1】:

    这段代码 sn-p 显示了如何从 MSXML2.XMLHTTP 使用的文件夹中删除缓存文件,使用下载文件将具有扩展名“.csv”的概念

    <job>
    <script language="vbscript">
    
    ' use XMLHTTP to grab content from a URL
    
    CMEURL = "ftp://ftp.cmegroup.com/pub/settle/nymex_future.csv"
    
    ' the downloaded files are being stored in a subfolder of this folder
    filedownloadcachelocation =  "C:\Users\user\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5"
    
    ' delete the file before requesting a download
    
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    Dim fileresults 
    
    Dim Directory
    Set Directory = fso.GetFolder(filedownloadcachelocation)
    Dim subfolders
    Set subfolders = Directory.SubFolders
    For Each Folder In subfolders
        For Each FileName In Folder.Files
            ' only react if filename extension is csv
            If InStr(FileName , ".csv") Then
                fileresults = fileresults & FileName.Path & vbLf 
    
                ' delete the file
                If fso.FileExists(FileName.Path) Then
                    'WScript.Echo "deleting file " & FileName.Path
                    fso.DeleteFile FileName.Path
                End If
    
    
            End If ' csv ext
        Next ' each file in folder
    Next ' each folder in Content.IE5
    
    WScript.Echo "files found that were deleted = " & VbLf & fileresults
    
    ' now continue with downloading the file using XMLHTTP
    

    【讨论】:

      猜你喜欢
      • 2012-04-13
      • 2015-07-31
      • 2014-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-18
      • 2017-12-29
      • 1970-01-01
      相关资源
      最近更新 更多