使用Powershell在Internet Explorer中获取页面的URL [英] Get URL of page in Internet Explorer using Powershell

查看:302
本文介绍了使用Powershell在Internet Explorer中获取页面的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PowerShell脚本,它将打开一个Internet Explorer实例,转到某个网站并找到一个隐藏的链接,但是当我转到该链接时,它将我重定向到另一个页面.

I have a PowerShell script which will open an instance of internet explorer, go to a certain website and find a hidden link but when I go to that link it redirects me to another page.

我想找到Internet Explorer现在所在页面的URL,并将其存储在变量中.

I'd like to find the URL of the page that internet explorer is now in to be stored in a variable.

谢谢!

对于只阅读代码的人:

$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.

推荐答案

因此,如果您尝试获取文档的当前位置,则可以使用:$IE.Document.url

So if you are trying to get the current location of a document then you can use : $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

这篇关于使用Powershell在Internet Explorer中获取页面的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆