File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 11FROM public.ecr.aws/lambda/python:3.9 as build
22RUN yum install -y unzip && \
3- curl -SL https://chromedriver.storage.googleapis.com/2.43 /chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4- curl -SL https://github. com/adieuadieu/serverless-chrome/releases/ download/v1.0.0-55/stable-headless- chromium-amazonlinux-2017-03 .zip > /tmp/headless-chromium .zip && \
3+ curl -SL https://chromedriver.storage.googleapis.com/89.0.4389.23 /chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4+ curl -SL https://www.googleapis. com/download/storage/v1/b/ chromium-browser-snapshots/o/Linux_x64%2F843831%2Fchrome-linux .zip?alt=media > /tmp/chrome-linux .zip && \
55 unzip /tmp/chromedriver.zip -d /opt/ && \
6- unzip /tmp/headless-chromium .zip -d /opt/
6+ unzip /tmp/chrome-linux .zip -d /opt/
77
88FROM public.ecr.aws/lambda/python:3.9
9- RUN yum install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
9+ RUN yum install atk cups-libs gtk3 libXcomposite alsa-lib \
10+ libXcursor libXdamage libXext libXi libXrandr libXScrnSaver \
11+ libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb \
12+ xorg-x11-xauth dbus-glib dbus-glib-devel -y
1013RUN pip install selenium
11- COPY --from=build /opt/headless-chromium /opt/
14+ COPY --from=build /opt/chrome-linux /opt/chrome
1215COPY --from=build /opt/chromedriver /opt/
1316COPY test.py ./
1417CMD [ "test.handler" ]
Original file line number Diff line number Diff line change 33
44def handler (event = None , context = None ):
55 options = webdriver .ChromeOptions ()
6- options .binary_location = " /opt/headless-chromium"
6+ options .binary_location = ' /opt/chrome/chrome'
77 options .add_argument ('--headless' )
88 options .add_argument ('--no-sandbox' )
99 options .add_argument ("--disable-gpu" )
1010 options .add_argument ("--window-size=1280x1696" )
1111 options .add_argument ("--single-process" )
1212 options .add_argument ("--disable-dev-shm-usage" )
13+ options .add_argument ("--disable-dev-tools" )
14+ options .add_argument ("--no-zygote" )
15+ options .add_argument ("--user-data-dir=/tmp/chrome-user-data" )
16+ options .add_argument ("--remote-debugging-port=9222" )
1317 chrome = webdriver .Chrome ("/opt/chromedriver" ,
1418 options = options )
15- chrome .get ("https://umihi.co /" )
19+ chrome .get ("https://example.com /" )
1620 return chrome .find_element_by_xpath ("//html" ).text
You can’t perform that action at this time.
0 commit comments