Skip to content

Commit 8a0e53e

Browse files
committed
Update CDP Mode examples
1 parent ab88595 commit 8a0e53e

File tree

8 files changed

+15
-20
lines changed

8 files changed

+15
-20
lines changed

examples/cdp_mode/raw_ad_blocking.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ async def block_urls(tab):
77
await tab.send(mycdp.network.enable())
88
await tab.send(mycdp.network.set_blocked_urls(
99
urls=[
10-
"*googlesyndication.com*",
11-
"*googletagmanager.com*",
12-
"*google-analytics.com*",
13-
"*amazon-adsystem.com*",
14-
"*adsafeprotected.com*",
15-
"*doubleclick.net*",
16-
"*fastclick.net*",
17-
"*snigelweb.com*",
18-
"*2mdn.net*",
10+
"*.googlesyndication.com*",
11+
"*.googletagmanager.com*",
12+
"*.google-analytics.com*",
13+
"*.amazon-adsystem.com*",
14+
"*.adsafeprotected.com*",
15+
"*.doubleclick.net*",
16+
"*.fastclick.net*",
17+
"*.snigelweb.com*",
18+
"*.2mdn.net*",
1919
]
2020
))
2121

examples/cdp_mode/raw_cdp_gitlab.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
url = "https://gitlab.com/users/sign_in"
44
sb = sb_cdp.Chrome(url, incognito=True)
5-
sb.sleep(2.2)
65
sb.solve_captcha()
76
sb.highlight('h1:contains("GitLab")')
87
sb.highlight('button:contains("Sign in")')

examples/cdp_mode/raw_gitlab.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
with SB(uc=True, test=True, locale="en") as sb:
44
url = "https://gitlab.com/users/sign_in"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2)
76
sb.solve_captcha()
87
# (The rest is for testing and demo purposes)
98
sb.assert_text("Username", '[for="user_login"]', timeout=3)

examples/cdp_mode/raw_glassdoor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with SB(uc=True, test=True, ad_block=True) as sb:
44
url = "https://www.glassdoor.com/Reviews/index.htm"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2.2)
6+
sb.sleep(1.2)
77
sb.solve_captcha()
88
sb.highlight('[data-test="global-nav-glassdoor-logo"]')
99
sb.highlight('[data-test="site-header-companies"]')

examples/cdp_mode/raw_planetmc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with SB(uc=True, test=True) as sb:
44
url = "www.planetminecraft.com/account/sign_in/"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2)
6+
sb.sleep(1.2)
77
sb.solve_captcha()
88
sb.wait_for_element_absent("input[disabled]")
99
sb.sleep(2)

examples/cdp_mode/raw_science.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
url = "https://earth.esa.int/eogateway/search"
55
sb.activate_cdp_mode(url)
66
sb.sleep(1)
7-
sb.cdp.click_if_visible('button:contains("Accept cookies")')
7+
sb.click_if_visible('button:contains("Accept cookies")')
88
for i in range(20):
9-
sb.cdp.scroll_to_bottom()
10-
sb.cdp.click_if_visible('button:contains("READ MORE")')
9+
sb.scroll_to_bottom()
10+
sb.click_if_visible('button:contains("READ MORE")')
1111
sb.sleep(1)
12-
elements = sb.cdp.find_elements("h4 a span")
12+
elements = sb.find_elements("h4 a span")
1313
for element in elements:
1414
print(element.text)
1515
print("*** Total entries: %s" % len(elements))

examples/cdp_mode/raw_timezone.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def main():
2626
)
2727
sb.add_handler(mycdp.fetch.RequestPaused, request_paused_handler)
2828
sb.remove_elements("#right-sidebar")
29-
sb.remove_elements('[id*="Footer"]')
3029
sb.sleep(6)
3130
sb.driver.stop()
3231

examples/cdp_mode/raw_timezone_sb.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
url = "https://www.randymajors.org/what-time-zone-am-i-in"
66
sb.activate_cdp_mode(url, tzone="Asia/Kolkata", geoloc=(26.863, 80.94))
77
sb.remove_elements("#right-sidebar")
8-
sb.remove_elements('[id*="Footer"]')
98
sb.sleep(5)
109
sb.cdp.open(url, tzone="Asia/Tokyo", geoloc=(35.050681, 136.844728))
1110
sb.remove_elements("#right-sidebar")
12-
sb.remove_elements('[id*="Footer"]')
1311
sb.sleep(5)

0 commit comments

Comments
 (0)