如何在 PowerShell 中使用 Invoke-WebRequest 获得网站链接?
要使用 PowerShell 获取网站上的链接,我们可以首先使用 Invoke-WebRequest cmdlet 从网页中检索数据。
$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req
输出

要仅检索链接,我们可以使用该属性,在那里您还会找到一些子属性,如 InnerHTML、Innertext、href 等,如输出所示。
$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req.Links
输出
innerHTML : Scripts innerText : Scripts outerHTML : <A href="https://theautomationcode.com/scripts/">Scripts</A> outerText : Scripts tagName : A href : https://theautomationcode.com/scripts/
我们只需要链接,所以我们将使用 href 属性。
$req.Links | Select -ExpandProperty href
输出
https://theautomationcode.com/2020/11/ https://theautomationcode.com/author/chiragce17/ https://theautomationcode.com/category/powershell/ https://theautomationcode.com/category/troubleshooting/
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP