我创建了一个使用 Internet explore 11 登录到 https 网站的小脚本。我手动单击鼠标将文件下载到 IE,但我收到保存打开文件的提示我希望能够绕过这个因为我打算在后台运行这个?我是否在 ie.navigate(url) 末尾缺少一个参数来保存文件?正如我上面所说,我为此使用 IE11,降级不是一种选择。
任何帮助都会很棒
$username= get-content -Path c:\username.txt
$password= get-content -Path c:\password.txt
$ie = New-Object -ComObject internetExplorer.Application
$ie.Visible= $false
$ie.fullscreen = $false
$ie.Navigate("https://www.mft1.firstdataclients.com/cgi-bin/messageway/mwi.cgi")
while ($ie.Busy -eq $true){Start-Sleep -seconds 2}
$usernamefield = $ie.Document.getElementByID('user')
$usernamefield.value = $username
$passwordfield = $ie.Document.getElementByID('password')
$passwordfield.value = $password
$ie.document.getElementById("request").click()
while ($ie.Busy -eq $true){Start-Sleep -seconds 2}
$ie.Navigate("https://www.mft1.firstdataclients.com/cgi-bin/messageway/mwi.cgi? request=ViewDownloaded")
while ($ie.Busy -eq $true){Start-Sleep -seconds 2}
$ie.Document.getElementsByTagName('a')| where-object {$_.href -match "request=TextDownload"} | where-object {$_.href -match 'CL9DFMDE'}| select -First 1 -ExpandProperty 'href'
$link=$ie.Document.getElementsByTagName('a')| where-object {$_.href -match "request=TextDownload"} | where-object {$_.href -match 'CL9DFMDE'}| select -First 1 -ExpandProperty 'href'
$file= $link
$filename= [string]($file).substring(122)
$filename
$ie.Navigate("$file")