html 如何在powershell2.0中进行web scapping

dfuffjeb  于 2023-04-27  发布在  Shell
关注(0)|答案(1)|浏览(128)

我尝试了下面的解决方案,基本上从URL检索表信息,或者只是HTML内容形式的URL,但它不工作在Powershell2.0,因为我可以在Powershell5.0中运行这个相同的脚本,请帮助我找到一些解决方案

$url= "https:\\somewebsite"
$WebRequest = New-Object System.Net.WebClient
$WebRequest.UseDefaultCredentials = $true
$html = $WebRequest.DownloadString($url)
6ovsh4lw

6ovsh4lw1#

PowerShell 2.0没有-UseDefaultCredentials
将其更改为使用.Credentials

$url = "https://somewebsite"
$WebRequest = New-Object System.Net.WebClient
$WebRequest.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$html = $WebRequest.DownloadString($url)

相关问题