【问题标题】:Invoke-WebRequest not showing the desired informationInvoke-WebRequest 未显示所需信息
【发布时间】:2017-03-23 13:33:32
【问题描述】:

我正在尝试从谷歌浏览器页面Chrome Download提取当前版本号

使用 Invoke-Web 请求,我可以从网站上获取大量信息,而不是我正在寻找的那一点信息

这是我能得到的最接近的,这是行,但我想我需要显示类名才能得到我想要的

$WebResponse = Invoke-WebRequest "https://enterprise.google.com/intl/en_version/chrome/chrome-browser/"
($WebResponse.ParsedHtml.getElementById("main")| foreach{$_.getElementsByTagName("span")})[0]

【问题讨论】:

    标签: powershell


    【解决方案1】:

    您可以为此使用 omahaproxy,您将能够获得一个包含每个平台的 chrome 版本详细信息的 csv,您可以像这样解析它:

    $WebResponse = Invoke-WebRequest "https://omahaproxy.appspot.com/all" 
    $csv = $WebResponse.Content | convertfrom-csv
    
    ($csv | ?{($_.os -eq 'win64') -and ($_.channel -eq 'stable')}).current_version
    

    【讨论】:

    • 谢谢你,我什至不知道这是一个选项。只是出于兴趣,以防我想为其他项目做这件事。我试图做的事情是否可能?
    • @LiamMatthews 这将是$WebResponse = Invoke-WebRequest "https://enterprise.google.com/intl/en_version/chrome/chrome-browser/"; ($webresponse.parsedhtml.getElementsByTagName("div")| Where {$_.getAttributeNode('class').Value -eq 'version'}).outerhtml 的代码,如果您看到它只会加载的输出。我假设他们正在使用一些 ajax 调用来获取它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多