File tree Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 44with SB (uc = True , test = True , locale_code = "en" ) as sb :
55 url = "https://www.cloudflare.com/login"
66 sb .activate_cdp_mode (url )
7- sb .sleep (2 )
7+ sb .sleep (3 )
88 sb .uc_gui_handle_captcha () # PyAutoGUI press Tab and Spacebar
99 sb .sleep (2 )
1010
Original file line number Diff line number Diff line change 44with SB (uc = True , test = True , ad_block = True ) as sb :
55 url = "https://chatgpt.com/"
66 sb .activate_cdp_mode (url )
7+ sb .sleep (1 )
8+ sb .click_if_visible ('button[aria-label="Close dialog"]' )
79 query = "Compare Playwright to SeleniumBase in under 178 words"
810 sb .press_keys ("#prompt-textarea" , query )
911 sb .click ('button[data-testid="send-button"]' )
1012 print ('*** Input for ChatGPT: ***\n "%s"' % query )
13+ sb .sleep (3 )
1114 with suppress (Exception ):
12- # The "Send" button reappears when ChatGPT is done typing a response
13- sb .wait_for_element ('button[data-testid="send-button"]' , timeout = 22 )
15+ # The "Stop" button disappears when ChatGPT is done typing a response
16+ sb .wait_for_element_not_visible (
17+ 'button[data-testid="stop-button"]' , timeout = 20
18+ )
1419 chat = sb .find_element ('[data-message-author-role="assistant"] .markdown' )
1520 soup = sb .get_beautiful_soup (chat .get_html ()).get_text ("\n " ).strip ()
1621 print ("*** Response from ChatGPT: ***\n %s" % soup .replace ("\n :" , ":" ))
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ async def crawl():
6565 # Change url to something that makes ajax requests
6666 tab = await driver .get ("https://learn.microsoft.com/en-us/" )
6767 time .sleep (2 )
68- for i in range (75 ):
69- await tab .scroll_down (3 )
68+ for i in range (20 ):
69+ await tab .scroll_down (4 )
7070 time .sleep (0.02 )
7171
7272 xhr_responses = await receiveXHR (tab , xhr_requests )
@@ -87,6 +87,5 @@ async def crawl():
8787
8888if __name__ == "__main__" :
8989 print ("<============= START: XHR Example =============>" )
90- loop = asyncio .new_event_loop ()
91- loop .run_until_complete (crawl ())
90+ asyncio .run (crawl ())
9291 print ("<============== END: XHR Example ==============>" )
Original file line number Diff line number Diff line change @@ -64,8 +64,8 @@ async def receiveXHR(page, requests):
6464 # Change url to something that makes ajax requests
6565 sb .cdp .open ("https://learn.microsoft.com/en-us/" )
6666 time .sleep (2 )
67- for i in range (15 ):
68- sb .cdp .scroll_down (15 )
67+ for i in range (10 ):
68+ sb .cdp .scroll_down (8 )
6969
7070 loop = sb .cdp .get_event_loop ()
7171 xhr_responses = loop .run_until_complete (receiveXHR (tab , xhr_requests ))
Original file line number Diff line number Diff line change 11"""SB Manager using UC Mode for evading bot-detection."""
22from seleniumbase import SB
33
4- with SB (uc = True , test = True ) as sb :
4+ with SB (uc = True , test = True , disable_csp = True ) as sb :
55 url = "https://steamdb.info/"
66 sb .uc_open_with_reconnect (url , 3 )
77 sb .uc_click ("a.header-login span" , 3 )
88 sb .uc_gui_click_captcha ()
9- sb .assert_text ("Sign in" , "button#js-sign-in" )
9+ sb .assert_text ("Sign in" , "button#js-sign-in" , timeout = 4 )
1010 sb .uc_click ("button#js-sign-in" , 2 )
1111 sb .highlight ("div.page_content form" )
1212 sb .highlight ('button:contains("Sign in")' , scroll = False )
13- sb .sleep (1 )
13+ sb .set_messenger_theme (location = "top_center" )
14+ sb .post_message ("SeleniumBase wasn't detected" , duration = 4 )
You can’t perform that action at this time.
0 commit comments