py3chrome


Namepy3chrome JSON
Version 0.2.9 PyPI version JSON
download
home_pagehttps://github.com/ostorlab/py3chrome
SummaryA Python Package for the Google Chrome Dev Protocol
upload_time2024-03-07 14:36:47
maintainer
docs_urlNone
authorfate0
requires_python
licenseBSD license
keywords pychrome
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pychrome

[![Updates](https://pyup.io/repos/github/fate0/pychrome/shield.svg)](https://pyup.io/repos/github/ostorlab/py3chrome/)
[![PyPI](https://img.shields.io/pypi/v/pychrome.svg)](https://pypi.python.org/pypi/py3chrome)
[![PyPI](https://img.shields.io/pypi/pyversions/pychrome.svg)](https://github.com/ostorlab/py3chrome)

A Python Package for the Google Chrome Dev Protocol, [more document](https://fate0.github.io/pychrome/)

## Table of Contents

* [Installation](#installation)
* [Setup Chrome](#setup-chrome)
* [Getting Started](#getting-started)
* [Tab management](#tab-management)
* [Debug](#debug)
* [Examples](#examples)
* [Ref](#ref)


## 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](https://chromedevtools.github.io/devtools-protocol/tot/)


## Debug

set DEBUG env variable:

![pychrome_with_debug_env](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_with_debug_env.png)


## Tab management

run `pychrome -h` for more info

example:

![pychrome_tab_management](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_tab_management.png)


## Examples

please see the [examples](http://github.com/fate0/pychrome/blob/master/examples) directory for more examples


## Ref

* [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface/)
* [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ostorlab/py3chrome",
    "name": "py3chrome",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pychrome",
    "author": "fate0",
    "author_email": "fate0@fatezero.org",
    "download_url": "https://files.pythonhosted.org/packages/9a/0b/4849975abab45626e699df661846575181bf83789526d0289ab22931acd9/py3chrome-0.2.9.tar.gz",
    "platform": null,
    "description": "# pychrome\n\n[![Updates](https://pyup.io/repos/github/fate0/pychrome/shield.svg)](https://pyup.io/repos/github/ostorlab/py3chrome/)\n[![PyPI](https://img.shields.io/pypi/v/pychrome.svg)](https://pypi.python.org/pypi/py3chrome)\n[![PyPI](https://img.shields.io/pypi/pyversions/pychrome.svg)](https://github.com/ostorlab/py3chrome)\n\nA Python Package for the Google Chrome Dev Protocol, [more document](https://fate0.github.io/pychrome/)\n\n## Table of Contents\n\n* [Installation](#installation)\n* [Setup Chrome](#setup-chrome)\n* [Getting Started](#getting-started)\n* [Tab management](#tab-management)\n* [Debug](#debug)\n* [Examples](#examples)\n* [Ref](#ref)\n\n\n## Installation\n\nTo install pychrome, simply:\n\n```\n$ pip install -U pychrome\n```\n\nor from GitHub:\n\n```\n$ pip install -U git+https://github.com/fate0/pychrome.git\n```\n\nor from source:\n\n```\n$ python setup.py install\n```\n\n## Setup Chrome\n\nsimply:\n\n```\n$ google-chrome --remote-debugging-port=9222\n```\n\nor headless mode (chrome version >= 59):\n\n```\n$ google-chrome --headless --disable-gpu --remote-debugging-port=9222\n```\n\nor use docker:\n\n```\n$ docker pull fate0/headless-chrome\n$ docker run -it --rm --cap-add=SYS_ADMIN -p9222:9222 fate0/headless-chrome\n```\n\n## Getting Started\n\n```\nimport pychrome\n\n# create a browser instance\nbrowser = pychrome.Browser(url=\"http://127.0.0.1:9222\")\n\n# create a tab\ntab = browser.new_tab()\n\n\n# register callback if you want\ndef request_will_be_sent(**kwargs):\n    print(\"loading: %s\" % kwargs.get('request').get('url'))\n\n\ntab.Network.requestWillBeSent = request_will_be_sent\n\n# start the tab \ntab.start()\n\n# call method\ntab.Network.enable()\n# call method with timeout\ntab.Page.navigate(url=\"https://github.com/fate0/pychrome\", _timeout=5)\n\n# wait for loading\ntab.wait(5)\n\n# stop the tab (stop handle events and stop recv message from chrome)\ntab.stop()\n\n# close tab\nbrowser.close_tab(tab)\n\n```\n\nor (alternate syntax)\n\n```\nimport pychrome\n\nbrowser = pychrome.Browser(url=\"http://127.0.0.1:9222\")\ntab = browser.new_tab()\n\ndef request_will_be_sent(**kwargs):\n    print(\"loading: %s\" % kwargs.get('request').get('url'))\n\n\ntab.set_listener(\"Network.requestWillBeSent\", request_will_be_sent)\n\ntab.start()\ntab.call_method(\"Network.enable\")\ntab.call_method(\"Page.navigate\", url=\"https://github.com/fate0/pychrome\", _timeout=5)\n\ntab.wait(5)\ntab.stop()\n\nbrowser.close_tab(tab)\n```\n\nmore methods or events could be found in\n[Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/)\n\n\n## Debug\n\nset DEBUG env variable:\n\n![pychrome_with_debug_env](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_with_debug_env.png)\n\n\n## Tab management\n\nrun `pychrome -h` for more info\n\nexample:\n\n![pychrome_tab_management](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_tab_management.png)\n\n\n## Examples\n\nplease see the [examples](http://github.com/fate0/pychrome/blob/master/examples) directory for more examples\n\n\n## Ref\n\n* [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface/)\n* [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/)\n",
    "bugtrack_url": null,
    "license": "BSD license",
    "summary": "A Python Package for the Google Chrome Dev Protocol",
    "version": "0.2.9",
    "project_urls": {
        "Homepage": "https://github.com/ostorlab/py3chrome"
    },
    "split_keywords": [
        "pychrome"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a47d7975287c21f66bcdddfa7a39a64ab195435568062a883b2298b29eb352c",
                "md5": "8d0dc705cddec06f9d2864c59ca5afaf",
                "sha256": "af0bde75a32b66a3546eb22c9f72200d4cd7383a48a3ed1110e4353aaa2160be"
            },
            "downloads": -1,
            "filename": "py3chrome-0.2.9-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d0dc705cddec06f9d2864c59ca5afaf",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8209,
            "upload_time": "2024-03-07T14:36:46",
            "upload_time_iso_8601": "2024-03-07T14:36:46.298052Z",
            "url": "https://files.pythonhosted.org/packages/0a/47/d7975287c21f66bcdddfa7a39a64ab195435568062a883b2298b29eb352c/py3chrome-0.2.9-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a0b4849975abab45626e699df661846575181bf83789526d0289ab22931acd9",
                "md5": "8aaa1e9512bb369b436ea1b0dcddc65b",
                "sha256": "e522f2444c4fe27b95d41e6bfe6e024aa76b501663918cfc949ea4a49d4396c0"
            },
            "downloads": -1,
            "filename": "py3chrome-0.2.9.tar.gz",
            "has_sig": false,
            "md5_digest": "8aaa1e9512bb369b436ea1b0dcddc65b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10884,
            "upload_time": "2024-03-07T14:36:47",
            "upload_time_iso_8601": "2024-03-07T14:36:47.856971Z",
            "url": "https://files.pythonhosted.org/packages/9a/0b/4849975abab45626e699df661846575181bf83789526d0289ab22931acd9/py3chrome-0.2.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-07 14:36:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ostorlab",
    "github_project": "py3chrome",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "py3chrome"
}
        
Elapsed time: 0.47328s