0

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"

1 Answer 1

1

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."
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.