- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get website links using Invoke-WebRequest in PowerShell?
To get the links present on the website using PowerShell, we can first retrieve the data from the webpage using the Invoke-WebRequest cmdlet.
$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req
Output
To retrieve only links we can use that property and there you will also find some sub-properties like InnerHTML, Innertext, href, etc as shown in the output.
$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req.Links
Output
innerHTML : Scripts innerText : Scripts outerHTML : <A href="https://theautomationcode.com/scripts/">Scripts</A> outerText : Scripts tagName : A href : https://theautomationcode.com/scripts/
We need only links so we will use the href property.
$req.Links | Select -ExpandProperty href
Output
https://theautomationcode.com/2020/11/ https://theautomationcode.com/author/chiragce17/ https://theautomationcode.com/category/powershell/ https://theautomationcode.com/category/troubleshooting/
Advertisements