【Python】爬虫问题解决

问题如下:

/usr/bin/python2.7 /media/hao/000804B800006CAD/2018/BG/CODE/HaoCodes/Spider/baidu-music-spider-master/baidu-music-spider-master/testcase/login163.py
Traceback (most recent call last):
  File "/media/hao/000804B800006CAD/2018/BG/CODE/HaoCodes/Spider/baidu-music-spider-master/baidu-music-spider-master/testcase/login163.py", line 19, in <module>
    driver = webdriver.Chrome()
  File "/home/hao/.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
    self.service.start()
  File "/home/hao/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

 

解决办法:

提示chrome driver没有放置在正确的路径下,于是下载chrome dirver,然后放置到/usr/bin的目录下,再次运行就OK了! 

OS Expected Location of Chrome
Linux /usr/bin/google-chrome1
Mac /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe

需要根据自己的chrome浏览器版本,来下载对应版本相应包,我的版本师62,所以下载2.35版本,如下:

 

https://chromedriver.storage.googleapis.com/index.html?path=2.35/

chrome浏览器路径:/opt/google/chrome/chrome

安装selenium:pip install selenium

chrome driver下载路径:http://chromedriver.chromium.org/downloads

 

posted @ 2018-05-14 23:16  念槐聚  阅读(376)  评论(0)    收藏  举报