PowerShell का उपयोग करके वेबसाइट पर मौजूद लिंक प्राप्त करने के लिए, हम पहले Invoke-WebRequest कमांडलेट का उपयोग करके वेबपेज से डेटा प्राप्त कर सकते हैं।
$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/