Skip to content

Instantly share code, notes, and snippets.

@rcy
Created May 23, 2023 17:28
Show Gist options
  • Save rcy/07f320847c56354b07162e4441b08b6d to your computer and use it in GitHub Desktop.
Save rcy/07f320847c56354b07162e4441b08b6d to your computer and use it in GitHub Desktop.
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 ?")
@rcy
Copy link
Author

rcy commented May 23, 2023

@jablko check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment