GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ClericPy/ichrome: Chrome controller for Humans, based on Chrome Devtools Protocol(CDP) and python3.7+.

BranchesTags
Open more actions menu

Latest commit

 

History

527 Commits
527 Commits

Folders and files

NameName
Last commit message
Last commit date
demo
demo
 
 
docs
docs
 
 
ichrome
ichrome
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
demo.py
demo.py
 
 
examples_async.py
examples_async.py
 
 
examples_debug.py
examples_debug.py
 
 
mkdocs.yml
mkdocs.yml
 
 
pyproject.toml
pyproject.toml
 
 
requirements.txt
requirements.txt
 
 
structure.png
structure.png
 
 
use_cases.py
use_cases.py
 
 

Repository files navigation

ichrome PyPIPyPI - WheelPyPI - Python VersionPyPI - DownloadsPyPI - License


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

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

uvx --from ichrome ichrome.http
or
python -m ichrome.http
then view the interactive API docs at http://localhost:8080/docs

Want to add your own endpoints? Wrap tab operations as business logic into HTTP routes. See demo/custom_routes_guide.py for a quick guide.

image

If you encounter any problems, please let me know through issues; your feedback is valuable for enhancing 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 confusing
    • Event-driven architecture (EDA) is not always ideal.
  • Selenium is slow
    • Webdriver often comes with memory leaks
      • PhantomJS development is suspended
    • No native coroutine (asyncio) support
  • Playwright arrived too late
    • This may be a good choice for both sync and async usage
      • The original author of puppeteer joined the team.
    • But its core code is based on Node.js, which is hard to monkey-patch.

Features

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

  • A process daemon for 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 process 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

About

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

pypi.org/project/ichrome/

Topics

cdpchromechrome-controllerchrome-daemonchrome-devtools-protocolchrome-process-daemondaemonheadlesspythonpython3python37torequestswebdriver

Resources

Readme
MIT license
Activity

Stars

256 stars

Watchers

7 watching

Forks

29 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.