【问题标题】:Powershell web scraping IE drop down not updating valuesPowershell网络抓取IE下拉不更新值
【发布时间】:2017-11-09 00:04:10
【问题描述】:

我目前正在尝试在 PowerShell 中开发一个脚本,该脚本可以打开 Internet Explorer,更改两个下拉值(更新表格值),然后最好将表格抓取到 CSV 文件。

顺便说一句,该站点有一个静态 URL,更改下拉列表不会更改 URL:(

我可以让 IE 打开并更改两个下拉值,但在此之后表格没有更新其值... 我认为这与站点代码有关,它显示此下拉列表的选项为:

<select id="pricing-display-by-dropdown" 
onchange="$('html').trigger('rate.changed', this.value)">
 <option value="hour">Hour</option>
 <option value="month">Month</option>
</select>

所以到目前为止,基本上我所拥有的就是这个,它会改变地区和定价,但不会更新表格,也许必须以某种方式触发上面的触发器?:

$url = "https://azure.microsoft.com/en-us/pricing/details/sql-database/" 
$ie = New-Object -com internetexplorer.application; 
$ie.visible = $true; 
$ie.navigate($url); 
while ($ie.Busy() -and $ie.ReadyState -ne 4){ sleep -Milliseconds 6000 }

$ie.Document.IHTMLDocument3_getElementByID("region-selector").value = "europe-north"

$ie.Document.IHTMLDocument3_getElementByID("pricing-display-by-dropdown").value = "month"

任何帮助将不胜感激,我是 PowerShell 和 stackoverflow 的新手,所以请原谅任何愚蠢的事情

【问题讨论】:

    标签: html powershell internet-explorer scripting screen-scraping


    【解决方案1】:

    给你

    $ie.Document.IHTMLDocument3_getElementByID("pricing-display-by-dropdown").fireEvent("onchange")
    

    【讨论】:

      猜你喜欢
      • 2019-07-15
      • 2019-08-25
      • 2021-11-08
      • 2019-04-26
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 1970-01-01
      相关资源
      最近更新 更多