|
2 | 2 | from selenium.webdriver.chrome.options import Options
|
3 | 3 | import os
|
4 | 4 |
|
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" |
22 | 5 |
|
23 |
| -driver = webdriver.Chrome(chrome_options=chrome_options) |
24 | 6 |
|
25 | 7 | def lambda_handler(event, context):
|
26 | 8 | # TODO implement
|
27 | 9 | 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) |
28 | 29 | page_data = ""
|
29 | 30 | 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) |
33 | 34 | driver.close()
|
34 | 35 | return page_data
|
0 commit comments