Linux上的Selenium:selenium.common.exceptions.WebDriverException:消息:“ chromedriver_linux64”可执行文件可能具有错误的权限

时间:2019-07-08 06:05:15

标签: python-3.x web-scraping beautifulsoup

我正尝试使用漂亮的汤和熊猫库在Web上为我的项目剪贴一个特定页面。但是,在执行代码时,即使提供了chrome浏览器路径,我也会收到此错误。我该怎么做才能使我的代码运行?

我正在Linux上执行此代码,而我尝试这样做:

chromedriver = "/home/sharvari/Downloads/chromedriver_linux64"
 os.environ["webdriver.chrome.driver"] = chromedriver '''
 driver = webdriver.Chrome('chromedriver') 

代替我的原始代码:

import os
from Django.utils import timezone
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd

def fetch():
    driver = webdriver.Chrome('/home/sharvari/Downloads/chromedriver_linux64')
    driver.get("https://www.flipkart.com/search?q=iphone&otracker=search&otracker1=search&marketplace=FLIPKART&as-show=on&as=off")
    content = driver.page_source
    soup = BeautifulSoup(content)

我希望它打开我的Chrome浏览器并从提供的URL中获取数据。但是,相反,我被重定向到Chrome,然后显示此错误消息:

"
Traceback (most recent call last):
  File "/home/sharvari/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/home/sharvari/anaconda3/lib/python3.7/subprocess.py", line 769, in __init__
    restore_signals, start_new_session)
  File "/home/sharvari/anaconda3/lib/python3.7/subprocess.py", line 1516, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/sharvari/Downloads/chromedriver_linux64'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sharvari/Documents/Internship/Codes/webscrap.py", line 31, in <module>
    fetch()
  File "/home/sharvari/Documents/Internship/Codes/webscrap.py", line 15, in fetch
    driver = webdriver.Chrome('/home/sharvari/Downloads/chromedriver_linux64')
  File "/home/sharvari/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/home/sharvari/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver_linux64' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

0 个答案:

没有答案