Skip to content

Instantly share code, notes, and snippets.

@yashb042
Last active July 7, 2023 12:21
Show Gist options
  • Save yashb042/86837b26d5fad795bf54394922d39754 to your computer and use it in GitHub Desktop.
Save yashb042/86837b26d5fad795bf54394922d39754 to your computer and use it in GitHub Desktop.
Selenium Lambda Function
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