-
-
Save LoganGray/8aa2de1a079222d9e2ba39ecd207684e to your computer and use it in GitHub Desktop.
| #!/usr/bin/env bash | |
| # used to install offical chrome and selenium on Ubuntu 16.04.1 LTS, 18.04, 20.04.1 LTS desktop, Jan 2021 | |
| # also tested and works on Elem OS 5.1 :) | |
| # | |
| # make sure script is run as root or sudo | |
| if [[ $(whoami) != "root" ]] ; then | |
| echo ; echo "This script, $0, SHOULD be run as ROOT. " ; echo | |
| exit 1 | |
| fi | |
| # | |
| cd ~ | |
| sudo apt-get update | |
| sudo apt install python-pip | |
| pip install simplejson | |
| pip install bs4 | |
| pip install selenium | |
| sudo apt-get install -y libasound2 libnspr4 libnss3 libxss1 xdg-utils unzip libappindicator1 fonts-liberation | |
| apt-get -f install | |
| wget http://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
| sudo dpkg -i google-chrome*.deb | |
| # chromedriver also needs to be installed. | |
| CHROME_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE) | |
| wget https://chromedriver.storage.googleapis.com/$CHROME_VERSION/chromedriver_linux64.zip | |
| #wget http://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip | |
| unzip chromedriver_linux64.zip | |
| sudo mv chromedriver /usr/bin/chromedriver | |
| sudo chown root:root /usr/bin/chromedriver # questionable - may need to add other user permissions | |
| sudo chmod +x /usr/bin/chromedriver |
Thanks.
Seems we need install more dependency packages now
RUN apt-get install -y libappindicator3-1 libatk-bridge2.0-0 libatspi2.0-0 libgbm1 libgtk-3-0Here is whole Dockerfile I used.
FROM openjdk:8u232 # chrome-browser RUN apt-get update RUN apt-get install -y wget RUN apt-get install -y libasound2 libnspr4 libnss3 libxss1 xdg-utils unzip RUN apt-get install -y libappindicator1 fonts-liberation RUN apt-get install -y libappindicator3-1 libatk-bridge2.0-0 libatspi2.0-0 libgbm1 libgtk-3-0 RUN apt-get install -f RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb RUN dpkg -i google-chrome*.debThe part to install python and pip packages in your steps are not required and I can wget the chrome package via https without issue.
Interesting! However, this was not intended to be used in a docker file but for a Ubuntu server VPS or otherwise.
However, I will check if today if any mods need to be made to get it to work on Ubuntu 20, and
if I have time -
maybe a docker container as well. ;)
@LoganGray thank you very much.
After installing it, how to use chrome via cli in headless mode? What's the name of the command?
Hi. I believe I was using Selenium at the time - or was it Puppeteer? but anyway, I could actually expand on this a bit, and turn this into a full repo with examples if you like. I was trying to keep things very simple here and just do a single bash script - but if you'd like me to show a bit more, just let me know.
sudo apt install python-pip should be changed to sudo apt install -y python3-pip. python-pip does not exist on Ubuntu 20.04.
Genius thank you!!
I'm sorry,
I can't figure out where this was put, I checked my entire server on Linux, but I can't find the browser itself.
I need to specify the path to the browser.
const {join} = require('path');
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
Please tell me where can I find it?
@LoganGray
@LoganGray thank you very much.
After installing it, how to use chrome via cli in headless mode? What's the name of the command?