当前位置:   article > 正文

python的浏览器操作-selenium版本4更新操作_selenium更新

selenium更新
1.获取操作浏览器地址:
"C:\Program Files\Google\Chrome\Application\chrome.exe"

2.浏览器输入:chrome://version/,获取对应版本号

112.0.5615.50 (正式版本) (64 位) (cohort: Stable Installs & Version Pins) 

3.下载驱动器版本

http://chromedriver.storage.googleapis.com/index.html

4.把驱动解压,获取驱动地址

5.0.特别注意点:运行前把执行的浏览器窗口全部关闭

5.0.窗口关闭

5.0.关闭

5.1.使用原来插件的运行cmd运行命令:

"C:\Program Files\Google\Chrome\Application\chrome.exe"  --flag-switches-begin --flag-switches-end --remote-debugging-port=9226

5.2.使用新的环境,cmd命令

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9226 --user-data-dir="D:\user-chrome"

6.查看是否运行:

  1. # 查看所有进程
  2. tasklist |findstr chrome*
  3. # 查看进程的网络状态
  4. netstat -ano|findstr "9226"

7.直接上python命令

  1. # 下载浏览器对应版本的chromedriver.exe
  2. from selenium import webdriver
  3. from selenium.webdriver.chrome.options import Options
  4. from selenium.webdriver.chrome.service import Service
  5. def browser_now_05():
  6. # 启动115
  7. options_01 = Options()
  8. # chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:29887")
  9. # service_01 = Service = r"E:\down\chromedriver_win32_3_112.0.5615.49\chromedriver.exe"
  10. options_01.add_experimental_option("debuggerAddress", "127.0.0.1:9226")
  11. options_01.binary_location = r'C:\Users\用户名\AppData\Local\115Chrome\Application\115chrome.exe'
  12. # win32_2_83
  13. service_path = r"E:\down\chromedriver_win32_2_83.0.4103.39\chromedriver.exe"
  14. service_01 = Service(service_path)
  15. driver = webdriver.Chrome(service=service_01, options=options_01)
  16. driver.get('https://www.csdn.net/')
  17. # driver.get('https://baidu.com/')
  18. print(driver.title)
  19. if __name__ == "__main__":
  20. browser_now_05()

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

闽ICP备14008679号