-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain2.py
More file actions
25 lines (21 loc) · 1.07 KB
/
main2.py
File metadata and controls
25 lines (21 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from selenium.webdriver import Remote, ChromeOptions
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
SBR_WEBDRIVER = ''
def main():
print('Connecting to Scraping Browser...')
sbr_connection = ChromiumRemoteConnection(SBR_WEBDRIVER, 'goog', 'chrome')
with Remote(sbr_connection, options=ChromeOptions()) as driver:
print('Connected! Navigating to https://google.com...')
driver.get('https://google.com')
# CAPTCHA handling: If you're expecting a CAPTCHA on the target page, use the following code snippet to check the status of Scraping Browser's automatic CAPTCHA solver
# print('Waiting captcha to solve...')
# solve_res = driver.execute('executeCdpCommand', {
# 'cmd': 'Captcha.waitForSolve',
# 'params': {'detectTimeout': 10000},
# })
# print('Captcha solve status:', solve_res['value']['status'])
print('Navigated! Scraping page content...')
html = driver.page_source
print(html)
if __name__ == '__main__':
main()