Reputation: 1016
I have been trying to check if a word contains in a webpage. In a nutshell, I tried using:
invoke-WebRequest https://example.com | select-string "some text"
Upvotes: 0
Views: 1443
Reputation: 5928
Invoke-WebRequest
returns more than just the content of the web page (e.g. headers, response code, etc). You need to use the Content
property from the response to get to the content of the web page:
if ((Invoke-WebRequest "https://example.com").Content | Select-String "some text") {
Write-Host "I found the text."
}
Upvotes: 1