Last active
July 7, 2023 12:21
-
-
Save yashb042/86837b26d5fad795bf54394922d39754 to your computer and use it in GitHub Desktop.
Selenium Lambda Function
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 selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
def lambda_handler(event, context): | |
options = Options() | |
options.binary_location = '/opt/headless-chromium' | |
options.add_argument('--headless') | |
options.add_argument('--no-sandbox') | |
options.add_argument('--single-process') | |
options.add_argument('--disable-dev-shm-usage') | |
driver = webdriver.Chrome('/opt/chromedriver',chrome_options=options) | |
driver.get('https://www.google.com/') | |
title = driver.title | |
driver.close() | |
driver.quit() | |
response = { | |
"statusCode": 200, | |
"body": title | |
} | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment