0

I am wondering if there is a way to see if a series of words exist on a web page using python.

For example, is there a way to write a function that will return true iff the words 'this site is good' are found on a given web page?

Ideally I would want this to work using a web page in the chrome browser, and I am only worried about the same text that would show up if you used ctrl+f in chrome.

Thanks!

Initially I thought that you could use pynput to manually ctrl+f in chrome but I don't know how you would get a function to return true if the results of chrome's find feature are true.

tteo57
  • 7
  • 2
  • 1
    You can use **regex** in python to find the words and match it. For extracting the words/content from website you can go with `urllib` , `requests` , and many packages. – amrs-tech Sep 13 '19 at 04:53
  • 1
    What amrs-tech said with a caveat, if the text is generated using JS you will have to use a a few more packages – DanielAaron Sep 13 '19 at 05:08

1 Answers1

0

As show here in this answer, you can use BeautifulSoup which is a HTML parsing package and a package like urllib or Requests in order to get the page itself.

Alternatively, you could use Selenium or Requestium, which is a mix between Selenium and Requests, in order to do that as shown here

Then you just needed to

def selenium_code():
    pass

if selenium_code == True:
    print("The words have been found")