How to click on the first result on google using selenium python

前端 未结 3 1549
情书的邮戳
情书的邮戳 2021-01-03 06:23

I am trying to click on the first result on the google result. Here is my code where I am entering chennai craiglist which is read from csv file. So I am sure the first lin

3条回答
  •  [愿得一人]
    2021-01-03 06:49

    This works great with google results.

    results = driver.find_elements_by_xpath('//div[@class="r"]/a/h3')  # finds webresults
    results[0].click(). # clicks the first one
    

提交回复
热议问题