()
| 7 | |
| 8 | @decorators.print_runtime("CDP Proxy Example") |
| 9 | def 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 | |
| 51 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…