{"id":13936559,"url":"https://github.com/pokemonish/chrome_remote_interface_python","last_synced_at":"2025-07-19T22:30:52.703Z","repository":{"id":80756334,"uuid":"89893149","full_name":"pokemonish/chrome_remote_interface_python","owner":"pokemonish","description":"Chrome Debugging Protocol interface for Python","archived":false,"fork":false,"pushed_at":"2018-05-24T22:21:22.000Z","size":172,"stargazers_count":109,"open_issues_count":0,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-27T04:31:16.281Z","etag":null,"topics":["chrome","chrome-debugging-protocol","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pokemonish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-01T02:59:35.000Z","updated_at":"2024-02-25T11:44:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"adc746b7-6df1-42f1-9c38-fa380dbe84f3","html_url":"https://github.com/pokemonish/chrome_remote_interface_python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pokemonish/chrome_remote_interface_python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokemonish%2Fchrome_remote_interface_python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokemonish%2Fchrome_remote_interface_python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokemonish%2Fchrome_remote_interface_python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokemonish%2Fchrome_remote_interface_python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokemonish","download_url":"https://codeload.github.com/pokemonish/chrome_remote_interface_python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokemonish%2Fchrome_remote_interface_python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266030792,"owners_count":23866616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","chrome-debugging-protocol","python"],"created_at":"2024-08-07T23:02:47.177Z","updated_at":"2025-07-19T22:30:52.387Z","avatar_url":"https://github.com/pokemonish.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"chrome-remote-interface-python\n=======================\n\n[Chrome Debugging Protocol] interface that helps to instrument Chrome (or any\nother suitable [implementation](#implementations)) by providing a simple\nabstraction of commands and notifications using a straightforward Python\nAPI.\n\nThis module is one of the many [third-party protocol clients][3rd-party].\n\nIt is only for Python 3.5 for now\n\n[3rd-party]: https://developer.chrome.com/devtools/docs/debugging-clients#chrome-remote-interface\n\nSample API usage\n----------------\n\nThe following snippet loads `https://github.com` and prints every response body length:\n\n```python\nimport asyncio\nimport chrome_remote_interface\n\nif __name__ == '__main__':\n    class callbacks:\n        async def start(tabs):\n            await tabs.add()\n        async def tab_start(tabs, tab):\n            await tab.Page.enable()\n            await tab.Network.enable()\n            await tab.Page.navigate(url='http://github.com')\n        async def network__loading_finished(tabs, tab, requestId, **kwargs):\n            try:\n                body = tabs.helpers.old_helpers.unpack_response_body(await tab.Network.get_response_body(requestId=requestId))\n                print('body length:', len(body))\n            except tabs.FailResponse as e:\n                print('fail:', e)\n        async def page__frame_stopped_loading(tabs, tab, **kwargs):\n            print('finish')\n            tabs.terminate()\n        async def any(tabs, tab, callback_name, parameters):\n            pass\n            # print('Unknown event fired', callback_name)\n\n    asyncio.get_event_loop().run_until_complete(chrome_remote_interface.Tabs.run('localhost', 9222, callbacks))\n```\n\nWe use these types of callbacks:\n* ```start(tabs)``` - fired on the start.\n* ```tab_start(tabs, tab, manual)``` - fired on tab create.\n* ```network__response_received(tabs, tab, **kwargs)``` - callback for chrome [Network.responseReceived](https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-responseReceived) event.\n* ```any(tabs, tab, callback_name, parameters)``` - fallback which fired when there is no callback found.\n* ```tab_close(tabs, tab)``` - fired when tab is closed\n* ```tab_suicide(tabs, tab)``` - fired when tab is closed without your wish (and socket too)\n* ```close(tabs)``` - fired when all tabs are closed\n\nWe can add tab using method ```tabs.add()``` and remove it with ```tabs[n].remove()``` or ```tab.remove()```.\n\nEach method can throw ```FailReponse``` exception when something goes wrong.\n\nYou can terminate your programm by calling ```tabs.terminate()```.\n\nInstallation\n------------\n\n```bash\ngit clone https://github.com/wasiher/chrome-remote-interface-python.git\npython3 setup.py install\n```\n\nSetup (all description from [here](https://github.com/cyrus-and/chrome-remote-interface))\n-----\n\nAn instance of either Chrome itself or another implementation needs to be\nrunning on a known port in order to use this module (defaults to\n`localhost:9222`).\n\n### Chrome/Chromium\n\n#### Desktop\n\nStart Chrome with the `--remote-debugging-port` option, for example:\n\n    google-chrome --remote-debugging-port=9222\n\n##### Headless\n\nSince version 57, additionally use the `--headless` option, for example:\n\n    google-chrome --headless --remote-debugging-port=9222\n\nPlease note that currently the *DevTools* methods are not properly supported in\nheadless mode; use the [Target domain] instead. See [#83] and [#84] for more\ninformation.\n\n[#83]: https://github.com/cyrus-and/chrome-remote-interface/issues/83\n[#84]: https://github.com/cyrus-and/chrome-remote-interface/issues/84\n[Target domain]: https://chromedevtools.github.io/debugger-protocol-viewer/tot/Target/\n\n#### Android\n\nPlug the device and enable the [port forwarding][adb], for example:\n\n    adb forward tcp:9222 localabstract:chrome_devtools_remote\n\n[adb]: https://developer.chrome.com/devtools/docs/remote-debugging-legacy\n\n##### WebView\n\nIn order to be inspectable, a WebView must\nbe [configured for debugging][webview] and the corresponding process ID must be\nknown. There are several ways to obtain it, for example:\n\n    adb shell grep -a webview_devtools_remote /proc/net/unix\n\nFinally, port forwarding can be enabled as follows:\n\n    adb forward tcp:9222 localabstract:webview_devtools_remote_\u003cpid\u003e\n\n[webview]: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews#configure_webviews_for_debugging\n\n### Edge\n\nInstall and run the [Edge Diagnostics Adapter][edge-adapter].\n\n[edge-adapter]: https://github.com/Microsoft/edge-diagnostics-adapter\n\n### Node.js\n\nStart Node.js with the `--inspect` option, for example:\n\n    node --inspect=9222 script.js\n\n### Safari (iOS)\n\nInstall and run the [iOS WebKit Debug Proxy][iwdp].\n\n[iwdp]: https://github.com/google/ios-webkit-debug-proxy\n\nChrome Debugging Protocol versions\n----------------------------------\n\nYou can update it using this way (It will be downloaded automatically first time)\n\n```python\nimport chrome_remote_interface\nchrome_remote_interface.Protocol.update_protocol()\n```\n\nProtocols are loaded from [here](https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/core/inspector/browser_protocol.json) and [here](https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/Source/core/inspector/browser_protocol.json)\n\n\nContributors\n------------\n\n- [Me](https://github.com/wasiher)\n\nResources\n---------\n\n- [Chrome Debugging Protocol]\n- [Chrome Debugging Protocol Viewer](https://chromedevtools.github.io/debugger-protocol-viewer/)\n- [Chrome Debugging Protocol Google group](https://groups.google.com/forum/#!forum/chrome-debugging-protocol)\n- [devtools-protocol official repo](https://github.com/ChromeDevTools/devtools-protocol)\n- [Showcase Chrome Debugging Protocol Clients](https://developer.chrome.com/devtools/docs/debugging-clients)\n- [Awesome chrome-devtools](https://github.com/ChromeDevTools/awesome-chrome-devtools)\n\n[Chrome Debugging Protocol]: https://developer.chrome.com/devtools/docs/debugger-protocol\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokemonish%2Fchrome_remote_interface_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokemonish%2Fchrome_remote_interface_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokemonish%2Fchrome_remote_interface_python/lists"}