PowerShell,如何按下网络表单上的按钮

问题描述 投票:0回答:1
页面

https://schneegans.de/windows/unattend-generator

 是一种表单,可让您定义 
autounatted.xml
 中的内容以用于 Windows 自动安装,并生成包含所有这些选项的 URL。现在我已经从表单中的选项中获得了所需的内容,我想按表单上的 
Download file
 按钮,以便可以将 
autounattend.xml
 添加到我的系统中。我一直在尝试以下但没有成功。也许我使用了错误的方法来收集此 XML 文件?

如何使用此 URL 并触发此页面上的

Download file

 按钮(或在 PowerShell 中以任何其他方式收集 
autounattend.xml
 的相关 XML 数据)?

# URL of the page $url = "https://schneegans.de/windows/unattend-generator/?LanguageMode=Unattended&UILanguage=en-US&UserLocale=en-GB&KeyboardLayout=0809%3A00000809&GeoLocation=242&ProcessorArchitecture=amd64&ComputerNameMode=Custom&ComputerName=Win10&TimeZoneMode=Implicit&PartitionMode=Unattended&PartitionLayout=GPT&EspSize=300&RecoveryMode=Partition&RecoverySize=600&WindowsEditionMode=Unattended&WindowsEdition=pro&UserAccountMode=Unattended&AccountName0=Boss&AccountPassword0=boss&AccountGroup0=Administrators&AccountName1=User&AccountPassword1=user&AccountGroup1=Users&AccountName2=&AccountName3=&AccountName4=&AutoLogonMode=Own&PasswordExpirationMode=Default&LockoutMode=Default&DisableSystemRestore=true&EnableLongPaths=true&EnableRemoteDesktop=true&HardenSystemDriveAcl=true&AllowPowerShellScripts=true&DisableLastAccess=true&NoAutoRebootWithLoggedOnUsers=true&TurnOffSystemSounds=true&DisableAppSuggestions=true&ProcessAudit=true&ProcessAuditCommandLine=true&WifiMode=Skip&ExpressSettings=DisableAll&SystemScript0=&SystemScriptType0=Cmd&SystemScript1=&SystemScriptType1=Ps1&SystemScript2=&SystemScriptType2=Reg&SystemScript3=&SystemScriptType3=Vbs&DefaultUserScript0=&DefaultUserScriptType0=Reg&FirstLogonScript0=&FirstLogonScriptType0=Cmd&FirstLogonScript1=&FirstLogonScriptType1=Ps1&FirstLogonScript2=&FirstLogonScriptType2=Reg&FirstLogonScript3=&FirstLogonScriptType3=Vbs&UserOnceScript0=&UserOnceScriptType0=Cmd&UserOnceScript1=&UserOnceScriptType1=Ps1&UserOnceScript2=&UserOnceScriptType2=Reg&UserOnceScript3=&UserOnceScriptType3=Vbs&WdacMode=Skip" try { # Send request to the page $response = Invoke-WebRequest -Uri $url # Parse the HTML response $html = $response.ParsedHtml # Find the download button element $downloadButton = $html.querySelector('.btn.btn-primary') if ($downloadButton -eq $null) { Write-Host "Download button not found." } # Extract the download link $downloadLink = $downloadButton.getAttribute('href') # Download the file Invoke-WebRequest -Uri $downloadLink -OutFile "autounattend.xml" Write-Host "File downloaded successfully." } catch { Write-Host "Error occurred: $_" }
    
powershell web-scraping button
1个回答
0
投票
无需单击按钮 – 只需使用

viewdownload 操作即可:

$url = 'https://schneegans.de/windows/unattend-generator/view/?LanguageMode=...'; Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\autounattend.xml";
来源:我是该服务的作者。

© www.soinside.com 2019 - 2024. All rights reserved.