Skip to main content

Chrome controller for Humans, base on Chrome Devtools Protocol(CDP) and python3.7+. Read more: https://github.com/ClericPy/ichrome.

Project description

ichrome PyPIPyPI - WheelPyPI - Python VersionPyPI - DownloadsPyPI - License


Chrome controller for Humans, base on Chrome Devtools Protocol(CDP) and python3.7+. Read Docs

image

If you encounter any problems, please let me know through issues, some of them will be a good opinion for the enhancement of ichrome.

Install

pip install ichrome -U

Uninstall & Clear the user data folder

    $ python3 -m ichrome --clean
    $ pip uninstall ichrome

Quick Start

import asyncio
from ichrome import AsyncChromeDaemon


async def test():
    async with AsyncChromeDaemon() as cd:
        # create a new tab
        async with cd.connect_tab(index=None) as tab:
            await tab.goto('https://github.com/ClericPy/ichrome', timeout=5)
            print(await tab.title)
        # Privacy Mode, proxyServer arg maybe not work on Chrome, for `Target.createBrowserContext` is the EXPERIMENTAL feature(but chromium is ok).
        # https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-createBrowserContext
        async with cd.incognito_tab(proxyServer='http://127.0.0.1:8080') as tab:
            await tab.goto('https://httpbin.org/ip', timeout=5)
            print(await tab.html)


asyncio.run(test())

Read Docs

Why?

  • In desperate need of a stable toolkit to communicate with Chrome browser (or other Blink-based browsers such as Chromium)
    • ichrome includes fast http & websocket connections (based on aiohttp) within an asyncio environment
  • Pyppeteer is awesome
    • But I don't need so much, and the spelling of pyppeteer is confused
    • Event-driven architecture(EDA) is not always smart.
  • Selenium is slow
    • Webdriver often comes with memory leak
      • PhantomJS development is suspended
    • No native coroutine(asyncio) support
  • Playwright comes too late
    • This may be a good choice for both sync and async usage
      • The 1st author of puppeteer joined it.
    • But its core code is based on Node.js, which is too hard to monkey-patch.

Features

As we known, Javascript is the first-class citizen of the Browser world, so learn to use it with ichrome frequently.

  • A process daemon of Chrome instances
    • auto-restart
    • command-line usage
    • async environment compatible
  • Connect to an existing Chrome
  • Operations on Tabs under stable websocket
    • Commonly used functions
    • Incognito Mode
  • ChromeEngine as the progress pool
    • support HTTP api router with FastAPI (EXPERIMENTAL)
      • launch the chrome pool with python -m ichrome.web
        • python -m ichrome.web --help for usage
  • Flatten mode with sessionId
    • Create only 1 WebSocket connection
    • New in version 2.9.0
      • EXPERIMENTAL
      • Share the same Websocket connection and use sessionId to distinguish requests
    • After v3.0.1
      • AsyncTab._DEFAULT_FLATTEN = True
  • The install script of chromium
  • debug mode for sync usage with ichrome.debugger >4.0.0 (EXPERIMENTAL)

Project details


Release history Release notifications | RSS feed

This version

4.0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ichrome-4.0.2-py3-none-any.whl (69.9 kB view details)

Uploaded Python 3

File details

Details for the file ichrome-4.0.2-py3-none-any.whl.

File metadata

  • Download URL: ichrome-4.0.2-py3-none-any.whl
  • Upload date:
  • Size: 69.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for ichrome-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5767f24ce4dbfa7f48c65672c048b37dbfa39a262f1c0dd103bfc515ddf53749
MD5 e21180fa55238aa990eb055ad66656a3
BLAKE2b-256 f58d9f0543cca52e115d7dad145a37be1f4c0cd5fa8bc9636fb195c959c9a31d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page