Please help me to click on Google's favorite site with Python selenium

Asked 2 years ago, Updated 2 years ago, 92 views

url = 'site url'
driver.get(url)
# I'll connect it like this
page = driver.page_source
html = BeautifulSoup(page, 'html.parser')
find_tag = html.findAll('h3')
# h3 tag is the name of the sites that are exposed after searching keywords on Google
# You are about to enter the first site with the word TEST TITLE at the end of the searched site name.
for title in find_tag:
    title_name = title.text[-10:]
    if title_name == 'TEST TITLE':
         The coding that I want is
         I'd like to click on the site that corresponds to this place to fill it out.

I approached the xpath of each title location and gave a click event to the for statement in the div[] where the number changes, but when I looked more closely, the xpath structure of the title location (where h3 is located) of the Google site was different Is there any other way I can click on the site when I find TEST TITLE in that state?

python selenium selenium-webdrive beautifulsoup crawling

2022-09-22 16:47

1 Answers

How to click from xpath

btn = browser.find_elements_by_xpath("XPATH")[0]
btn.click()


2022-09-22 16:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.