Skip to main content

Chrome controller for Humans, base on Chrome Devtools Protocol(CDP) and python3.8+. 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.8+. Read Docs

🚀 [NEW] ichrome v6.0.0 is available! Now supporting ichrome.http - a RESTful API server to control Chrome via HTTP requests.

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())

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 aiohttp
      • python -m ichrome.http or uvx ichrome.http
      • python -m ichrome.http --help for usage
    • python -m ichrome.web (Removed since v6.0.0)
  • 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)

Breaking Changes

  1. v6.0.0
    1. ichrome.web module is removed, use ichrome.http instead.
    2. refactor the ChromeEngine method parameters.
      1. add wait condition before engine.do

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

ichrome-6.0.0.tar.gz (151.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ichrome-6.0.0-py3-none-any.whl (82.4 kB view details)

Uploaded Python 3

File details

Details for the file ichrome-6.0.0.tar.gz.

File metadata

  • Download URL: ichrome-6.0.0.tar.gz
  • Upload date:
  • Size: 151.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for ichrome-6.0.0.tar.gz
Algorithm Hash digest
SHA256 2f14cd362898831ef463455d5f032e6317713ed38e1c596e48bf125968a1ea8f
MD5 35cf62a1d0dbf643a310dd144b85d46b
BLAKE2b-256 cb35b0ab08458c401cc342134a7aa74b879882c0158a83925836eaa977068f4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ichrome-6.0.0-py3-none-any.whl
  • Upload date:
  • Size: 82.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for ichrome-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdb3f9d4fe78b765c431e1bba8248b59bf5003431dad87acb697e60b92c17fc4
MD5 44d0d9beb679b6f1dde1bd8e5f15200e
BLAKE2b-256 8e84a2c3cc1c66f1d5dddaa206d57399e93e9dd6b8d1e4c04c77e92d912faf33

See more details on using hashes here.

Supported by

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