0

I have a problem with finding text on page. I found solution for single occurrence like:

   if  "tutu"  in driver.page_source:
   else:

But now I'm looking for some solution to find 2 same text. ("tudu" and other "tudu")

3
  • if "this thing" in text and "other thing" in text: Commented Dec 27, 2021 at 18:38
  • But the problem is this thing and other thing is the same text Commented Dec 27, 2021 at 18:46
  • How are tudu and the other tudu connected/related? Commented Dec 27, 2021 at 18:48

1 Answer 1

2

Use the count() string method.

if driver.page_source.count("some text") == 2:

Incase, two or more than two is okay:

if driver.page_source.count("some text") >= 2:
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.