当前位置:   article > 正文

mac+python3+selenium 4

mac+python3+selenium 4

 下载自己的版本

ChromeDriver - WebDriver for Chrome - Downloadsicon-default.png?t=N7T8https://chromedriver.chromium.org/downloads

https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.jsonicon-default.png?t=N7T8https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json

 把下载好的程序 Google Chrome for Testing.app  解压到  /usr/local/bin/ 

双击打开试一下,如果打不开,
sudo xattr -d com.apple.quarantine /拖动APP
 然后重命名为 chromedriver
.app扩展名也去掉
 

  1. from selenium import webdriver
  2. from time import sleep
  3. from selenium.webdriver.common.by import By
  4. # 启动浏览器驱动
  5. driver = webdriver.Chrome()
  6. # 访问url
  7. driver.get('https://www.baidu.com')
  8. # 定位元素
  9. el = driver.find_element(By.ID, 'kw')
  10. # 执行自动化操作
  11. el.send_keys('热搜')
  12. driver.find_element(By.ID, 'su').click()
  13. # 休眠5秒
  14. sleep(5)
  15. # 关闭浏览器并释放进程资源
  16. # driver.quit()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/371965
推荐阅读
相关标签
  

闽ICP备14008679号