chromedriver使用硒刮 [英] chromedriver using selenium for scraping

查看:168
本文介绍了chromedriver使用硒刮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在命令中使用selenium加载chrome web驱动程序,但出现错误

I am trying to load chrome web driver using selenium in command but getting an error

1)我已将chrome浏览器和webdriver更新为最新版本 2)通过使用相同版本的chrome浏览器和驱动程序进行检查

1)I have updated my chrome browser and webdriver to the latest version 2)checked by using the same version of chrome browser and driver

from selenium import webdriver
driver=webdriver.Chrome('C:/Users/prasun.j/Desktop/chromedriver')

我希望弹出一个浏览器窗口,但会收到此错误

I expect to pop up a browser window but getting this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\prasun.j\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\prasun.j\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\prasun.j\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\prasun.j\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\prasun.j\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: failed to write automation extension zip
  (Driver info: chromedriver=73.0.3683.20 (8e2b610813e167eee3619ac4ce6e42e3ec622017),platform=Windows NT 10.0.14393 x86_64)

推荐答案

注意:

  • 确保您已经安装了硒包
  • 此处(最新)下载chromedriver.exe版本-73+)并将其插入您的代码中(请确保已解压缩).
  • 还将"/"替换为"\\".
  • 安装适当的Chrome驱动程序(73+),以便与chromedriver版本(也适用于73 +)
  • 检查下面的答案...
  • Be sure that you have already installed the selenium package
  • Download chromedriver.exe from here (newest version - 73+) and insert it in your code (be sure that is unzipped).
  • Also, replace "/" with "\\".
  • Install the proper Chrome driver (73+) so to be combined with chromedriver version (73+ too)
  • Check the answer below ...

这来自Chrome驱动程序官方网站:

This is from the the official Chrome Driver website:

正确用法:

driver=webdriver.Chrome('C:\\User\\prasun.j\\Desktop\\chromedriver.exe')

# or as @MosheSlavin answered 

driver=webdriver.Chrome(r'C:\Users\prasun.j\Desktop\chromedriver.exe')

这篇关于chromedriver使用硒刮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆