Created
April 2, 2018 18:45
-
-
Save hltbra/785e0c50ea9ddac84ef45057cb88c7ed to your computer and use it in GitHub Desktop.
Running a PoC of selenium + chromium + python
This file contains 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 chromefull:1 . | |
# Google Chrome needs some kernel permissions, | |
# more details at https://github.com/jessfraz/dockerfiles/issues/65 and https://serverfault.com/a/824920 | |
docker run --rm --cap-add=SYS_ADMIN chromefull:1 |
This file contains 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 | |
driver = webdriver.Chrome() | |
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 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 --no-install-recommends \ | |
xvfb \ | |
chromium \ | |
chromedriver | |
RUN pip install selenium | |
COPY app.py /app.py | |
COPY run.sh /run.sh | |
RUN chmod +x /run.sh | |
RUN useradd -r -U chrome | |
USER chrome | |
WORKDIR /tmp | |
ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/chromium | |
ENV DISPLAY=:99 | |
CMD /run.sh |
This file contains 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
#!/bin/bash | |
Xvfb :99 -screen 0 1440x900x24 &> /tmp/xvfb_log.txt & | |
python /app.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment