Skip to main content

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdp_chrome_tabs-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

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

Hashes for cdp_chrome_tabs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8410c8248624cd1da6fd74b8ce1ee63c1c70ee1ba908c5a3ee0e11914f88b4f
MD5 af1064d0ba07d8c4e9e98151bf2137a1
BLAKE2b-256 72d54045d70ffb6583968a32ffcd67306511f94457853bf6635fb1d0392b6ba6

See more details on using hashes here.

File details

Details for the file cdp_chrome_tabs-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cdp_chrome_tabs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6beb2db73da24f4dd71a718a4ec609b17bac29905994035530668a95df8d5fa2
MD5 625fd438bbe872f6aadec3cf67f7429b
BLAKE2b-256 6b9be8d8f171bf65799be15eadb229e439753aa310e94ea923127b7249369e8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page