A Python package to interact with Chrome tabs via Chrome DevTools Protocol
Project description
CDP Chrome Tabs
A Python package for interacting with Chrome tabs via the Chrome DevTools Protocol.
Installation
pip install cdp-chrome-tabs
Or install from source:
git clone https://github.com/guocity/cdp-chrome-tabs.git
cd cdp-chrome-tabs
pip install -e .
Prerequisites
For this package to work, Chrome must be running with remote debugging enabled. You can start Chrome with:
# On macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
# On Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
# On Linux
google-chrome --remote-debugging-port=9222
Usage
from cdp_chrome_tabs import ChromeTabs
# one line print active tab
print(f"Active Tab URL: {ChromeTabs().get_active_tab().url if ChromeTabs().get_active_tab() else 'No active tab'}")
# Get all tabs
tabs = chrome.get_all_tabs()
for tab in tabs:
print(f"Tab ID: {tab.id}")
print(f"Title: {tab.title}")
print(f"URL: {tab.url}")
print("---")
# Get the active tab
active_tab = chrome.get_active_tab()
if active_tab:
print(f"Active tab: {active_tab.title} - {active_tab.url}")
# Find a tab by ID
tab = chrome.get_tab_by_id("some-tab-id")
# Find a tab by URL (exact match)
tab = chrome.get_tab_by_url("https://www.example.com")
# Find a tab by URL (partial match)
tab = chrome.get_tab_by_url("example.com", partial_match=True)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cdp_chrome_tabs-0.1.0.tar.gz
(7.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdp_chrome_tabs-0.1.0.tar.gz.
File metadata
- Download URL: cdp_chrome_tabs-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8410c8248624cd1da6fd74b8ce1ee63c1c70ee1ba908c5a3ee0e11914f88b4f
|
|
| MD5 |
af1064d0ba07d8c4e9e98151bf2137a1
|
|
| BLAKE2b-256 |
72d54045d70ffb6583968a32ffcd67306511f94457853bf6635fb1d0392b6ba6
|
File details
Details for the file cdp_chrome_tabs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cdp_chrome_tabs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6beb2db73da24f4dd71a718a4ec609b17bac29905994035530668a95df8d5fa2
|
|
| MD5 |
625fd438bbe872f6aadec3cf67f7429b
|
|
| BLAKE2b-256 |
6b9be8d8f171bf65799be15eadb229e439753aa310e94ea923127b7249369e8f
|