File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 11FROM public.ecr.aws/lambda/python:3.8 as build
2- RUN mkdir -p /opt/bin/ && \
3- mkdir -p /tmp/downloads && \
4- yum install -y unzip && \
5- curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > /tmp/downloads/chromedriver.zip && \
6- curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-37/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/downloads/headless-chromium.zip && \
7- unzip /tmp/downloads/chromedriver.zip -d /opt/bin/ && \
8- unzip /tmp/downloads/headless-chromium.zip -d /opt/bin/
2+ RUN yum install -y unzip && \
3+ curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4+ curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-37/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/headless-chromium.zip && \
5+ unzip /tmp/chromedriver.zip -d /opt/ && \
6+ unzip /tmp/headless-chromium.zip -d /opt/
97
108FROM public.ecr.aws/lambda/python:3.8
11- RUN mkdir -p /opt/bin && pip install selenium
129RUN yum install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
13- COPY --from=build /opt/bin/headless-chromium /opt/bin/
14- COPY --from=build /opt/bin/chromedriver /opt/bin/
10+ RUN pip install selenium
11+ COPY --from=build /opt/headless-chromium /opt/
12+ COPY --from=build /opt/chromedriver /opt/
1513COPY test.py ./
1614CMD [ "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/bin/ headless-chromium"
6+ options .binary_location = "/opt/headless-chromium"
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- chrome = webdriver .Chrome ("/opt/bin/ chromedriver" ,
13+ chrome = webdriver .Chrome ("/opt/chromedriver" ,
1414 options = options )
1515 chrome .get ("https://umihi.co/" )
1616 return chrome .find_element_by_xpath ("//html" ).text
You can’t perform that action at this time.
0 commit comments