“Failed to decode response from marionette” message in Python/Firefox headless scraping script

前端 未结 7 2064
既然无缘
既然无缘 2020-12-03 03:29

Good Day, I\'ve done a number of searches on here and google and yet to find a solution that address this problem.

The scenario is:

I have a Python script (

7条回答
  •  一向
    一向 (楼主)
    2020-12-03 03:45

    Try this, for Ubuntu 16.04:

    1. Install firefox
    sudo apt update
    sudo apt install firefox
    
    1. Check that firefox is well installed
    which firefox
    

    Will return /usr/bin/firefox

    1. Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. For example:
    wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
    
    1. Extract the file with:
    tar -xvzf geckodriver*
    
    1. Make it executable:
    chmod +x geckodriver
    
    1. Move it to $PATH and give root access
    sudo mv geckodriver /usr/bin/
    cd /usr/bin
    sudo chown root:root geckodriver
    
    1. Install selenium
    pip3 install selenium
    
    1. Add firefox and geckodriver to $PATH
    sudo vim ~/.bashrc
    

    Add the two lines:

    export PATH=$PATH:"/usr/bin/firefox"
    export PATH=$PATH:"/usr/bin/geckodriver"
    
    1. Reboot your instance
    sudo reboot
    

提交回复
热议问题