webdriver.Chrome()不起作用

时间:2018-05-14 17:53:06

标签: python-3.x selenium selenium-webdriver web-scraping chrome-web-driver

我正在尝试使用Selenium和Python 3.我安装了Selenium和Chrome Webdriver。 Pip预装了Python 3.但是,我收到此错误消息。我昨天开始学习这门语言,所以如果错误是愚蠢的话,请善待。

代码

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")
driver.close()

错误消息

"C:\Users\Vraj Shroff\PycharmProjects\untitled\venv\Scripts\python.exe" 
"C:/Users/Vraj Shroff/.PyCharmCE2018.1/config/scratches/Hello World.py"
Traceback (most recent call last):
File "C:/Users/Vraj Shroff/.PyCharmCE2018.1/config/scratches/Hello World.py", line 4, in <module>
driver = webdriver.Chrome()
AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
Process finished with exit code 1

任何帮助都将不胜感激。谢谢。

3 个答案:

答案 0 :(得分:1)

为此,您必须下载稳定版的Chromedriver,然后它才能工作

转到此链接并下载-https://sites.google.com/a/chromium.org/chromedriver/home

答案 1 :(得分:0)

enter image description here

您忘记包含 Chrome驱动程序可执行文件路径位置,我的意思是您需要指定Chrome驱动程序所在的路径。如果您尚未下载,请先从here下载,然后将其包含在#include <stdio.h> #include <stdlib.h> int main() { char a[5]; scanf("%5c", a); int i = 0; while( i < 5 ) { printf("%c ", a[i]); i++; } return 0; } 模块中的路径位置,如下所示。

在我的情况下,它位于Chrome上。请参阅代码 -

C:\Users\iphoton\Downloads\Compressed\

已检查并且运行正常。

答案 2 :(得分:-1)

cd /var/log/apache2/
nano error.log

应该可以。它对我有用:)