File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ """Timezone example using CDP Mode without WebDriver"""
2+ import mycdp
3+ from seleniumbase import decorators
4+ from seleniumbase import sb_cdp
5+
6+
7+ async def request_paused_handler (event , tab ):
8+ r = event .request
9+ is_image = ".png" in r .url or ".jpg" in r .url or ".gif" in r .url
10+ if not is_image : # Let the data through
11+ tab .feed_cdp (mycdp .fetch .continue_request (request_id = event .request_id ))
12+ else : # Block the data (images)
13+ TIMED_OUT = mycdp .network .ErrorReason .TIMED_OUT
14+ tab .feed_cdp (mycdp .fetch .fail_request (event .request_id , TIMED_OUT ))
15+
16+
17+ @decorators .print_runtime ("Timezone CDP Example" )
18+ def main ():
19+ url = "https://www.randymajors.org/what-time-zone-am-i-in"
20+ sb = sb_cdp .Chrome (
21+ url ,
22+ ad_block = True ,
23+ lang = "bn" ,
24+ tzone = "Asia/Kolkata" ,
25+ geoloc = (26.855323 , 80.937710 )
26+ )
27+ sb .add_handler (mycdp .fetch .RequestPaused , request_paused_handler )
28+ sb .remove_elements ("#right-sidebar" )
29+ sb .remove_elements ('[id*="Footer"]' )
30+ sb .sleep (6 )
31+
32+
33+ if __name__ == "__main__" :
34+ main ()
You can’t perform that action at this time.
0 commit comments