pychrome
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:
Tab management
run pychrome -h for more info
example:
Examples
please see the examples directory for more examples
Publish
- install deps
pip install setuptools wheel twine - pacakge
python setup.py sdist bdist_wheel - upload
twine upload dist/*
Ref
Metadata
Release files for cc12703-pychrome 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cc12703_pychrome-0.2.6.tar.gz | 548.1 kB | Without provenance | Details for cc12703_pychrome-0.2.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cc12703_pychrome-0.2.6-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for cc12703_pychrome-0.2.6-py2.py3-none-any.whl |
Total release size: 556.5 kB
Release files / cc12703_pychrome-0.2.6.tar.gz
| Download URL | cc12703_pychrome-0.2.6.tar.gz |
|---|---|
| Size | 548.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e55929f869f03800bf26b5cb0d4a7ac526611c7b095e62104c400677a4dbe335
|
|
BLAKE2b-256 checksum How to use checksums |
dfa3de7b1f0293c7b68115e3b956d066f0a0dbb2093076f8310755c0b9bd8ee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.10.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.7
|
Release files / cc12703_pychrome-0.2.6-py2.py3-none-any.whl
| Download URL | cc12703_pychrome-0.2.6-py2.py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f0e8092d5dc9531268c5241b3747c7eb4932897c921367ddaae9fb03ca392cab
|
|
BLAKE2b-256 checksum How to use checksums |
8007db6df86e4ec0f5ca48866884e254fb9d859db3889babb3ac2c2511c618b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.10.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.7
|
Security for cc12703-pychrome 0.2.6
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.