File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
from seleniumbase import sb_cdp
2
2
3
3
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 )
6
6
sb .gui_click_captcha ()
7
7
sb .highlight ('h1:contains("GitLab.com")' )
8
8
sb .highlight ('button:contains("Sign in")' )
Original file line number Diff line number Diff line change 1
1
from seleniumbase import sb_cdp
2
2
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
+
3
12
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 )
14
18
if cf_cookie :
15
19
print ("cf_clearance cookie: %s" % cf_cookie .value )
16
20
else :
You can’t perform that action at this time.
0 commit comments