{"id":18519337,"url":"https://github.com/fate0/aiochrome","last_synced_at":"2025-04-09T08:32:14.676Z","repository":{"id":57408777,"uuid":"103648394","full_name":"fate0/aiochrome","owner":"fate0","description":"A Python Package for the Google Chrome Dev Protocol [asyncio base]","archived":false,"fork":false,"pushed_at":"2023-03-31T14:48:02.000Z","size":987,"stargazers_count":23,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T04:15:56.040Z","etag":null,"topics":["aiochrome","asyncio","chrome","chrome-debugging-protocol","chrome-devtools","headless","headless-chrome","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fate0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-15T11:12:29.000Z","updated_at":"2024-12-26T11:29:30.000Z","dependencies_parsed_at":"2022-09-13T04:50:42.905Z","dependency_job_id":null,"html_url":"https://github.com/fate0/aiochrome","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fate0%2Faiochrome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fate0%2Faiochrome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fate0%2Faiochrome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fate0%2Faiochrome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fate0","download_url":"https://codeload.github.com/fate0/aiochrome/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248003320,"owners_count":21031770,"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":["aiochrome","asyncio","chrome","chrome-debugging-protocol","chrome-devtools","headless","headless-chrome","python"],"created_at":"2024-11-06T17:16:07.003Z","updated_at":"2025-04-09T08:32:14.333Z","avatar_url":"https://github.com/fate0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aiochrome\n\n[![Build Status](https://travis-ci.org/fate0/aiochrome.svg?branch=master)](https://travis-ci.org/fate0/aiochrome)\n[![Codecov](https://img.shields.io/codecov/c/github/fate0/aiochrome.svg)](https://codecov.io/gh/fate0/aiochrome)\n[![Updates](https://pyup.io/repos/github/fate0/aiochrome/shield.svg)](https://pyup.io/repos/github/fate0/aiochrome/)\n[![PyPI](https://img.shields.io/pypi/v/aiochrome.svg)](https://pypi.python.org/pypi/aiochrome)\n[![PyPI](https://img.shields.io/pypi/pyversions/aiochrome.svg)](https://github.com/fate0/aiochrome)\n\nA Python Package for the Google Chrome Dev Protocol, [more document](https://fate0.github.io/aiochrome/)\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 aiochrome, simply:\n\n```\n$ pip install -U aiochrome\n```\n\nor from GitHub:\n\n```\n$ pip install -U git+https://github.com/fate0/aiochrome.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 \u003e= 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``` python\nimport asyncio\nimport aiochrome\n\n\nasync def main():\n    # create a browser instance\n    browser = aiochrome.Browser(url=\"http://127.0.0.1:9222\")\n\n    # create a tab\n    tab = await browser.new_tab()\n\n    # register callback if you want\n    async def request_will_be_sent(**kwargs):\n        print(\"loading: %s\" % kwargs.get('request').get('url'))\n\n    tab.Network.requestWillBeSent = request_will_be_sent\n\n    # start the tab\n    await tab.start()\n\n    # call method\n    await tab.Network.enable()\n    # call method with timeout\n    await tab.Page.navigate(url=\"https://github.com/fate0/aiochrome\", _timeout=5)\n\n    # wait for loading\n    await tab.wait(5)\n\n    # stop the tab (stop handle events and stop recv message from chrome)\n    await tab.stop()\n\n    # close tab\n    await browser.close_tab(tab)\n\n\nloop = asyncio.get_event_loop()\ntry:\n    loop.run_until_complete(main())\nfinally:\n    loop.close()\n```\n\nor (alternate syntax)\n\n``` python\nimport asyncio\nimport aiochrome\n\n\nasync def main():\n    browser = aiochrome.Browser(url=\"http://127.0.0.1:9222\")\n    tab = await browser.new_tab()\n\n    async def request_will_be_sent(**kwargs):\n        print(\"loading: %s\" % kwargs.get('request').get('url'))\n\n    tab.set_listener(\"Network.requestWillBeSent\", request_will_be_sent)\n\n    await tab.start()\n    await tab.call_method(\"Network.enable\")\n    await tab.call_method(\"Page.navigate\", url=\"https://github.com/fate0/aiochrome\", _timeout=5)\n\n    await tab.wait(5)\n    await tab.stop()\n\n    await browser.close_tab(tab)\n\n\nloop = asyncio.get_event_loop()\ntry:\n    loop.run_until_complete(main())\nfinally:\n    loop.close()\n\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![aiochrome_with_debug_env](https://raw.githubusercontent.com/fate0/aiochrome/master/docs/images/aiochrome_with_debug_env.png)\n\n\n## Tab management\n\nrun `aiochrome -h` for more info\n\nexample:\n\n![aiochrome_tab_management](https://raw.githubusercontent.com/fate0/aiochrome/master/docs/images/aiochrome_tab_management.png)\n\n\n## Examples\n\nplease see the [examples](http://github.com/fate0/aiochrome/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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffate0%2Faiochrome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffate0%2Faiochrome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffate0%2Faiochrome/lists"}