如何从PowerShell网站上获取链接的价值?
我想从其网站上获得最后一个版本的下载url,我编写了一个脚本,但是它返回了链接名称,我不知道如何获得
$web = Invoke-WebRequest -Uri "https://download.gimp.org/pub/gimp/v2.10/windows/"
$web.Links | Where-Object href -like '*exe' | select -Last 1 | select -expand href
上述代码返回链接名称(GIMP-2.10.32-setup)。 EXE文件) 但是我需要值(“ https://download.gimp.org/pub/gimp/v2.10/windows/windows/gimp-2.10.32-setup.exe”) 有人可以指导我如何做吗
I want to get download URL of the last version of GIMP from it's site ,I wrote a script but it returns the link name I do not know how to get the value
$web = Invoke-WebRequest -Uri "https://download.gimp.org/pub/gimp/v2.10/windows/"
$web.Links | Where-Object href -like '*exe' | select -Last 1 | select -expand href
the above code returne link name (gimp-2.10.32-setup.exe)
but I need the value ("https://download.gimp.org/pub/gimp/v2.10/windows/gimp-2.10.32-setup.exe")
can someone guide me how to do it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您知道呈现的URL是相对的。
只需亲自附加URL的根部。
附加说明
您可以将
last
和-expand
从2个选择语句中组合为1。You know that the url presented is relative.
Just append the root part of the URL yourself.
Additional Note
You can combine the
-Last
and-Expand
from your 2 select statements into 1.有几个下载网站与此GIMP页面完全相同或非常相似的布局,包括许多Apache项目,例如 tomcat 和 activemq 。过去,我写了一些功能来解析这些和其他页面,有趣的是,它也适用于此GIMP页面。我认为值得分享。
假设该地点通过了一个落后的斜线。如果要考虑任何一个,则可以将此简单的行添加到过程块中。
要获取最新版本,请这样调用此功能
,或者您可以在检索时扩展属性
There are several downloads sites with exactly the same or very similar layout to this GIMP page, including many Apache projects like Tomcat and ActiveMQ. I had written a little function to parse these and other pages in the past, and interestingly it also worked for this GIMP page. I thought it was worth sharing as such.
It's assumed the site passed in has a trailing slash. If you want to account for either, you can add this simple line to the process block.
To get the latest version, call the function like this
Or you could expand the property while retrieving