Unfortunately I have a little problem with the realization of my Python program. At one point I can't get any further. The program should do the following:
- Perform an automatic search for a specific keyword on the search engine "www.startpage.com".
- Then the page with the results should be read out (and here is the problem).
- The program should now count how often a certain word appears on the page with the search results.
The problem here is that I can't get the source code from the search results page. I only get the source code of the start page Does anyone know a solution?
Thanks in advance.
So far my program looks like this:
import selenium.webdriver as webdriver
def get_results(search_term):
#this is the site, where I want to do the search
url="https://www.startpage.com"
browser = webdriver.Firefox()
browser.get(url)
search_box = browser.find_element_by_id("q")
#search in the search box after the search term
search_box.send_keys(search_term)
search_box.submit()
#print(browser.page_source) would give the result of the startpage (not the result page)
sub="dog"
print(source_code.count("dog"))
#counts zero times because it searchs for "dog" at the startpage
get_results("dog")