Skip to content

Commit dfd1ce1

Browse files
no such session exception
1 parent 847326b commit dfd1ce1

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

lambda_function.py

+22-21
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
from selenium.webdriver.chrome.options import Options
33
import os
44

5-
chrome_options = Options()
6-
chrome_options.add_argument('--headless')
7-
chrome_options.add_argument('--no-sandbox')
8-
chrome_options.add_argument('--disable-gpu')
9-
chrome_options.add_argument('--window-size=1280x1696')
10-
chrome_options.add_argument('--user-data-dir=/tmp/user-data')
11-
chrome_options.add_argument('--hide-scrollbars')
12-
chrome_options.add_argument('--enable-logging')
13-
chrome_options.add_argument('--log-level=0')
14-
chrome_options.add_argument('--v=99')
15-
chrome_options.add_argument('--single-process')
16-
chrome_options.add_argument('--data-path=/tmp/data-path')
17-
chrome_options.add_argument('--ignore-certificate-errors')
18-
chrome_options.add_argument('--homedir=/tmp')
19-
chrome_options.add_argument('--disk-cache-dir=/tmp/cache-dir')
20-
chrome_options.add_argument('user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36')
21-
chrome_options.binary_location = os.getcwd() + "/bin/headless-chromium"
225

23-
driver = webdriver.Chrome(chrome_options=chrome_options)
246

257
def lambda_handler(event, context):
268
# TODO implement
279
print("Starting google.com")
10+
chrome_options = Options()
11+
chrome_options.add_argument('--headless')
12+
chrome_options.add_argument('--no-sandbox')
13+
chrome_options.add_argument('--disable-gpu')
14+
chrome_options.add_argument('--window-size=1280x1696')
15+
chrome_options.add_argument('--user-data-dir=/tmp/user-data')
16+
chrome_options.add_argument('--hide-scrollbars')
17+
chrome_options.add_argument('--enable-logging')
18+
chrome_options.add_argument('--log-level=0')
19+
chrome_options.add_argument('--v=99')
20+
chrome_options.add_argument('--single-process')
21+
chrome_options.add_argument('--data-path=/tmp/data-path')
22+
chrome_options.add_argument('--ignore-certificate-errors')
23+
chrome_options.add_argument('--homedir=/tmp')
24+
chrome_options.add_argument('--disk-cache-dir=/tmp/cache-dir')
25+
chrome_options.add_argument('user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36')
26+
chrome_options.binary_location = os.getcwd() + "/bin/headless-chromium"
27+
28+
driver = webdriver.Chrome(chrome_options=chrome_options)
2829
page_data = ""
2930
if 'url' in event.keys():
30-
driver.get(event['url'])
31-
page_data = driver.page_source
32-
print(page_data)
31+
driver.get(event['url'])
32+
page_data = driver.page_source
33+
print(page_data)
3334
driver.close()
3435
return page_data

lambda_function.zip

94 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)