使用PowerShell获取页面的URL在Internet Explorer中

问题描述 投票:0回答:1

我有一个PowerShell脚本这将打开Internet Explorer的一个实例,到了一定的网站,并找到一个隐藏的链接,但是当我去那个链接重定向我到另一页。

我想找到的Internet Explorer现在是在被存储在一个变量的页面的URL。

谢谢!

对于那些谁只读代码:

$IE = new-object -com internetexplorer.application
$IE.visible = $true
$Document = $IE.navigate2("example.com")
# Do stuff
$Document = $IE.navigate2($LinkIFound)
# It redirects me...
# TODO: Find URL of page I am now in.
powershell internet-explorer
1个回答
2
投票

所以,如果你想获得一个文档的当前位置,那么你可以使用:$IE.Document.url

$IE = new-object -com internetexplorer.application
$IE.visible = $true
$Document = $IE.navigate2("example.com")
# Do stuff
$OldUrl = $IE.Document.url
$Document = $IE.navigate2($LinkIFound)
sleep -seconds 3
$NewUrl = $IE.Document.url
© www.soinside.com 2019 - 2024. All rights reserved.