Powershell Web 数据获取
Powershell Web Data Fetching
我不确定我做错了什么。我正在尝试从下面的 URL 中获取数据。
但是我在 return 中使用下面的代码没有得到任何东西。
我要取什么 (34)
Powershell 代码
$downloadURL = 'https://example.html'
$downloadRequest = Invoke-WebRequest -Uri $downloadURL
结果
数据不在 Powershell 的输出代码中
页面是使用 JavaScript 动态创建的。使用 Invoke-WebRequest
cmdlet 很难获取数据。取而代之的是,尝试像这样使用 Internet Explorer COM 对象:
$url = 'https://example.com'
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $false
$ie.Navigate2($url)
while($ie.ReadyState -ne 4) { Start-Sleep 1 }
$ie.document.body.getElementsByClassName('example-class-name')::outerHTML
$ie.document.body.getElementsByClassName('example-class-name')::textContent
有关详细信息,请参阅 this article。
我不确定我做错了什么。我正在尝试从下面的 URL 中获取数据。
但是我在 return 中使用下面的代码没有得到任何东西。
我要取什么 (34)
Powershell 代码
$downloadURL = 'https://example.html'
$downloadRequest = Invoke-WebRequest -Uri $downloadURL
结果
数据不在 Powershell 的输出代码中
页面是使用 JavaScript 动态创建的。使用 Invoke-WebRequest
cmdlet 很难获取数据。取而代之的是,尝试像这样使用 Internet Explorer COM 对象:
$url = 'https://example.com'
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $false
$ie.Navigate2($url)
while($ie.ReadyState -ne 4) { Start-Sleep 1 }
$ie.document.body.getElementsByClassName('example-class-name')::outerHTML
$ie.document.body.getElementsByClassName('example-class-name')::textContent
有关详细信息,请参阅 this article。