unable to load Atom 'find_element' (Ubuntu &deepin)

PhantomJS:unable to load Atom ‘find_element’ (Ubuntu &deepin)


  1. 问题描述

    在ubuntu(deepin)下写python爬虫时,使用phantomjs模拟登陆,出现以下错误:

    Traceback (most recent call last):
      File "", line 20, in 
        driver.find_element_by_id('lst-ib').send_keys('something' + Keys.RETURN)
      File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 266, in find_element_by_id
        return self.find_element(by=By.ID, value=id_)
      File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 744, in find_element
        {'using': by, 'value': value})['value']
      File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute
        self.error_handler.check_response(response)
      File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
        raise exception_class(value)
    selenium.common.exceptions.WebDriverException: Message: Error - Unable to load Atom 'find_element' from file ':/ghostdriver/./third_party/webdriver-atoms/find_element.js'
    
  2. 问题原因

    安装phantomjs时,采用apt-get install phantomjs方式安装,但它不是一个全功能的phantomjs版本.

  3. 解决办法

    1.卸载旧版本
    apt purge phantomjs
    2.通过Wget下载phantomjs
    wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    3.解压
    tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
    4.将phantomjs文件移动到/usr/bin/
    sudo cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/
    

你可能感兴趣的:(爬虫)