Skip to main content

Chrome Debugging Protocol client

Project description

CProto is a Debugging Protocol client that supports Chrome, Chromium and Blink based browsers.

CProto provides you an advanced interface to interact with Chrome (or another supported browser) instance from your Python code. It’s greatly useful for automated testing, debugging, profiling or even complicated page crawling.

This project is under development. More updates are coming soon.

Getting Started

Installing CProto

Python 2.7 or 3.3+ is required to install CProto.

Install the latest version using pip:

$ pip install cproto

Running Chrome in Debug mode

Option 1: Run Chrome in Docker, also in Headless mode.

Option 2: Run Chrome on host machine:

# «chrome» should point to your installation of Chrome
chrome --remote-debugging-port=9222 "about:blank"

# If you haven't created alias for Chrome yet, you could set it on MacOS like that:
# For Chrome
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
# For Chrome Canary
alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
# For Chromium
alias chromium="/Applications/Chromium.app/Contents/MacOS/Chromium"

Documentation

Chrome Debugging Protocol documentation.

CProto complies to official Chrome Debugging Protocol, which implicates CProto’s interface has the same API as Chrome Debugging Protocol. Consider this example:

from cproto import CProto

# Create CProto instance and connect to Chrome over CDP
cp = CProto(host='127.0.0.1', port=9222)

# Use Page to navigate to github.com.
cp.Page.navigate(url='https://github.com')

As you see, Page Domain API could be used to navigate any arbitrary URL (github in this case). There are a whole bunch of other methods and events available for each Domain, so you could browse all of them in the CDP documentation.

Roadmap

  • [x] Domains support

  • [x] Methods support

  • [x] Events support

  • [ ] Types support

  • TBA – suggestions are welcome

Chrome Headless

While Chrome Headless mode is only available for Linux (MacOS coming soon), you could use Docker to run Headless mode on any major OS.

# Build Docker image for Chrome Headless:
$ docker build -t headless .

# Run Docker Chrome Headless mode container with port 9222 being proxied to the host machine:
$ docker run --rm -it --cap-add=SYS_ADMIN -p 9222:9222 headless

# That's all here. Chrome Debugging interface is now listening for connections.
# You could check it out by opening this link in your browser – http://localhost:9222.

Examples

Check out examples directory.

More examples are coming soon.

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

cproto-0.2.3.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

cproto-0.2.3-py2.py3-none-any.whl (45.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cproto-0.2.3.tar.gz.

File metadata

  • Download URL: cproto-0.2.3.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cproto-0.2.3.tar.gz
Algorithm Hash digest
SHA256 583aea93b55863dd76d50a5bc474c22dc5ea0f53eb3690109a297b66f7c22906
MD5 0cb6333cf0041108c121b086eec09ad3
BLAKE2b-256 687d521b3a55fc9f3bb071217c8e1e83989f93e982952deb0252eadd6bda94db

See more details on using hashes here.

File details

Details for the file cproto-0.2.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cproto-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 62415635c25e09983a3c3166862d4a723ca074089a418cd280209d1495acd258
MD5 74ac7f9df45e1748140e22a887d6dc93
BLAKE2b-256 817e5f53f0245b0c170bc3f72f2b577b9b7d635f7f9843d23a081aaceced4ee9

See more details on using hashes here.

Supported by

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