【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 @   念槐聚  阅读(367)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
历史上的今天:
2013-05-14 [原]文件比较小技巧
2012-05-14 [转载]Openstack Essex安装文档资料
点击右上角即可分享
微信分享提示