MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / main

Function main

examples/cdp_mode/raw_proxy.py:9–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8@decorators.print_runtime("CDP Proxy Example")
9def main():
10 sb = sb_cdp.Chrome(lang="en", pls="none", proxy=proxy)
11 sb.goto("https://api.ipify.org/")
12 ip_address = sb.get_text("body")
13 if "ERR" in ip_address:
14 raise Exception("Failed to determine IP Address!")
15 print("\n\nMy IP Address = %s\n" % ip_address)
16 sb.goto("https://ipinfo.io/%s" % ip_address)
17 sb.sleep(2)
18 sb.wait_for_text(ip_address, "h1", timeout=20)
19 sb.wait_for_element('[href="/signup"]')
20 sb.wait_for_text("Hosted domains", timeout=20)
21 sb.highlight("h1")
22 pop_up = '[role="dialog"] span.cursor-pointer'
23 sb.click_if_visible(pop_up)
24 sb.highlight("section#summary")
25 sb.click_if_visible(pop_up)
26 sb.highlight("section#geolocation")
27 sb.click_if_visible(pop_up)
28 sb.sleep(2)
29 print("Displaying Host Info:")
30 text = sb.get_text("#summary").split("Hosted domains")[0]
31 rows = text.split("\n")
32 data = []
33 for row in rows:
34 if row.strip() != "":
35 data.append(row.strip())
36 print("\n".join(data).replace('\n"', ' "'))
37 print("\nDisplaying GeoLocation Info:")
38 text = sb.get_text("#geolocation")
39 text = text.split("IP Geolocation data")[0]
40 rows = text.split("\n")
41 data = []
42 for row in rows:
43 if row.strip() != "":
44 data.append(row.strip())
45 print("\n".join(data).replace('\n"', ' "'))
46 sb.click_if_visible(pop_up)
47 sb.sleep(3)
48 sb.quit()
49
50
51if __name__ == "__main__":

Callers 1

raw_proxy.pyFile · 0.70

Calls 8

quitMethod · 0.95
gotoMethod · 0.45
get_textMethod · 0.45
sleepMethod · 0.45
wait_for_textMethod · 0.45
wait_for_elementMethod · 0.45
highlightMethod · 0.45
click_if_visibleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…