Skip to main content

pychrome

Updates PyPI PyPI

A Python Package for the Google Chrome Dev Protocol, more document

Table of Contents

Installation

To install pychrome, simply:

$ pip install -U pychrome

or from GitHub:

$ pip install -U git+https://github.com/fate0/pychrome.git

or from source:

$ python setup.py install

Setup Chrome

simply:

$ google-chrome --remote-debugging-port=9222

or headless mode (chrome version >= 59):

$ google-chrome --headless --disable-gpu --remote-debugging-port=9222

or use docker:

$ docker pull fate0/headless-chrome
$ docker run -it --rm --cap-add=SYS_ADMIN -p9222:9222 fate0/headless-chrome

Getting Started

import pychrome

# create a browser instance
browser = pychrome.Browser(url="http://127.0.0.1:9222")

# create a tab
tab = browser.new_tab()


# register callback if you want
def request_will_be_sent(**kwargs):
    print("loading: %s" % kwargs.get('request').get('url'))


tab.Network.requestWillBeSent = request_will_be_sent

# start the tab 
tab.start()

# call method
tab.Network.enable()
# call method with timeout
tab.Page.navigate(url="https://github.com/fate0/pychrome", _timeout=5)

# wait for loading
tab.wait(5)

# stop the tab (stop handle events and stop recv message from chrome)
tab.stop()

# close tab
browser.close_tab(tab)

or (alternate syntax)

import pychrome

browser = pychrome.Browser(url="http://127.0.0.1:9222")
tab = browser.new_tab()

def request_will_be_sent(**kwargs):
    print("loading: %s" % kwargs.get('request').get('url'))


tab.set_listener("Network.requestWillBeSent", request_will_be_sent)

tab.start()
tab.call_method("Network.enable")
tab.call_method("Page.navigate", url="https://github.com/fate0/pychrome", _timeout=5)

tab.wait(5)
tab.stop()

browser.close_tab(tab)

more methods or events could be found in Chrome DevTools Protocol

Debug

set DEBUG env variable:

pychrome_with_debug_env

Tab management

run pychrome -h for more info

example:

pychrome_tab_management

Examples

please see the examples directory for more examples

Ref

Metadata

Release files for py3chrome 0.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py3chrome 0.2.9
File Size Uploaded Provenance Actions
py3chrome-0.2.9.tar.gz 10.9 kB Without provenance Details for py3chrome-0.2.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py3chrome 0.2.9
File Interpreter ABI Platform Actions
py3chrome-0.2.9-py2.py3-none-any.whl Python 3, Python 2 none any Details for py3chrome-0.2.9-py2.py3-none-any.whl

Total release size: 19.1 kB

Release files / py3chrome-0.2.9.tar.gz

Download URL py3chrome-0.2.9.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e522f2444c4fe27b95d41e6bfe6e024aa76b501663918cfc949ea4a49d4396c0
BLAKE2b-256 checksum
How to use checksums
9a0b4849975abab45626e699df661846575181bf83789526d0289ab22931acd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / py3chrome-0.2.9-py2.py3-none-any.whl

Download URL py3chrome-0.2.9-py2.py3-none-any.whl
Size 8.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
af0bde75a32b66a3546eb22c9f72200d4cd7383a48a3ed1110e4353aaa2160be
BLAKE2b-256 checksum
How to use checksums
0a47d7975287c21f66bcdddfa7a39a64ab195435568062a883b2298b29eb352c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for py3chrome 0.2.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page