Skip to content

Commit 07230e3

Browse files
committed
Update CDP Mode examples
1 parent 04ad1fb commit 07230e3

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

examples/cdp_mode/raw_cdp_gitlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from seleniumbase import sb_cdp
22

33
url = "https://gitlab.com/users/sign_in"
4-
sb = sb_cdp.Chrome(url)
5-
sb.sleep(2.5)
4+
sb = sb_cdp.Chrome(url, incognito=True)
5+
sb.sleep(2.2)
66
sb.gui_click_captcha()
77
sb.highlight('h1:contains("GitLab.com")')
88
sb.highlight('button:contains("Sign in")')

examples/cdp_mode/raw_cf_clearance.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
from seleniumbase import sb_cdp
22

3+
4+
def get_cf_clearance_cookie(sb):
5+
all_cookies = sb.get_all_cookies()
6+
for cookie in all_cookies:
7+
if cookie.name == "cf_clearance":
8+
return cookie
9+
return None
10+
11+
312
url = "https://gitlab.com/users/sign_in"
4-
sb = sb_cdp.Chrome(url)
5-
sb.sleep(2.2)
6-
sb.gui_click_captcha()
7-
sb.sleep(2)
8-
cf_cookie = None
9-
all_cookies = sb.get_all_cookies()
10-
for cookie in all_cookies:
11-
if cookie.name == 'cf_clearance':
12-
cf_cookie = cookie
13-
break
13+
sb = sb_cdp.Chrome(url, incognito=True)
14+
sb.sleep(2.2) # Wait for CAPTCHA to load
15+
sb.gui_click_captcha() # (Only if found)
16+
sb.sleep(2.2) # Wait for CAPTCHA success
17+
cf_cookie = get_cf_clearance_cookie(sb)
1418
if cf_cookie:
1519
print("cf_clearance cookie: %s" % cf_cookie.value)
1620
else:

0 commit comments

Comments
 (0)