[英]Automation: How to get downloaded path of a file that was downloaded from the Web browser
I am writing a automation script to download a excel file from a link that was opened using Chrome Browser.我正在编写一个自动化脚本,以从使用 Chrome 浏览器打开的链接下载 excel 文件。 Is there a option to get full path of the downloaded Location?
是否可以选择获取下载位置的完整路径? This script is going to be run across different machines.
该脚本将在不同的机器上运行。 So i do not want to specify the default download location in my system and find the file in that path.
所以我不想在我的系统中指定默认下载位置并在该路径中找到文件。
I have also tried using Windows CMD where i input the file name in CMD, searches the entire system and pulls the path.我也尝试过使用 Windows CMD 在 CMD 中输入文件名,搜索整个系统并提取路径。 But it is taking around 2 to 3 minutes to do this search.
但是进行此搜索大约需要 2 到 3 分钟。 Is there any better efficient method like using a JavaScript to get the downloaded location quicker?
有没有更有效的方法,比如使用 JavaScript 来更快地获取下载位置?
Below is the windows command i tried (taking 2 to 3 minutes)..下面是我试过的 windows 命令(需要 2 到 3 分钟)..
for /f "delims=" %i in ('dir "<FILENAME>" /b/a-d/od/t:c/s')
DO echo %i > %tmp%\lastfile.txt
It's the same in JScript.在 JScript 中也是如此。 It writes a web file to stdout.
它将 web 文件写入标准输出。
Sub HttpGet
On Error Resume Next
Set File = CreateObject("Microsoft.XMLHTTP")
File.Open "GET", Arg(1), False
File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
File.Send
txt=File.ResponseText
'Putting in line endings
Outp.write txt
If err.number <> 0 then
Outp.writeline ""
Outp.writeline "Error getting file"
Outp.writeline "=================="
Outp.writeline ""
Outp.writeline "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description
Outp.writeline "Source " & err.source
Outp.writeline ""
Outp.writeline "HTTP Error " & File.Status & " " & File.StatusText
Outp.writeline File.getAllResponseHeaders
Outp.writeline LCase(Arg(1))
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.