Last active
April 2, 2018 21:33
-
-
Save hltbra/3e9f02492389fdf9255f59dc9c24c485 to your computer and use it in GitHub Desktop.
Docker + Selenium POC with headless Chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t poc-selenium:1 . | |
docker run --rm poc-selenium:1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from selenium import webdriver | |
options = webdriver.ChromeOptions() | |
options.binary_location = '/usr/bin/google-chrome-stable' | |
options.add_argument('headless') | |
options.add_argument('no-sandbox') | |
driver = webdriver.Chrome(chrome_options=options) | |
driver.get("https://httpbin.org/ip") | |
print("IP: {}".format(driver.page_source)) | |
driver.get("https://httpbin.org/headers") | |
print("Headers: {}".format(driver.page_source)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:2.7 | |
RUN apt-get update && \ | |
apt-get install -y locales-all apt-transport-https unzip && \ | |
curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \ | |
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ | |
apt-get update && \ | |
apt-get install -y google-chrome-stable && \ | |
wget https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip && \ | |
unzip chromedriver_linux64.zip && \ | |
mv chromedriver /usr/bin/ | |
RUN pip install selenium | |
COPY app.py /app.py | |
CMD python /app.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment