Created
May 23, 2023 17:28
-
-
Save rcy/07f320847c56354b07162e4441b08b6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib.request | |
# Chrome's debugging protocol is accessible on localhost port 9222 | |
url = "http://localhost:9222/json" | |
try: | |
with urllib.request.urlopen(url) as response: | |
tabs = json.loads(response.read().decode()) | |
for tab in tabs: | |
print(f"Title: {tab['title']}") | |
print(f"URL: {tab['url']}") | |
print("-----------------------") | |
except urllib.error.URLError: | |
print("Couldn't connect to Chrome. Did you start it with --remote-debugging-port=9222 ?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jablko check it out