All Projects → fake-name → Chromecontroller

fake-name / Chromecontroller

Licence: other
Comprehensive wrapper and execution manager for the Chrome browser using the Chrome Debugging Protocol.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Chromecontroller

Ferrum
Headless Chrome Ruby API
Stars: ✭ 1,009 (+605.59%)
Mutual labels:  chrome, chromium
Html2image
A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.
Stars: ✭ 69 (-51.75%)
Mutual labels:  chrome, chromium
San Devtools
Browser developer tools extension for debugging San.
Stars: ✭ 51 (-64.34%)
Mutual labels:  chrome, chromium
Cuprite
Headless Chrome/Chromium driver for Capybara
Stars: ✭ 743 (+419.58%)
Mutual labels:  chrome, chromium
Surfingkeys Conf
A SurfingKeys configuration which adds 130+ key mappings for 20+ sites & OmniBar search suggestions for 50+ sites
Stars: ✭ 137 (-4.2%)
Mutual labels:  chrome, chromium
Cef2go
Go lang bindings for the Chromium Embedded Framework (CEF)
Stars: ✭ 780 (+445.45%)
Mutual labels:  chrome, chromium
Puppeteer Docs Zh Cn
Google Puppeteer 文档的中文版本 , 目标版本 1.9.0, 翻译中...
Stars: ✭ 61 (-57.34%)
Mutual labels:  chrome, chromium
Playwright Sharp
.NET version of the Playwright testing and automation library.
Stars: ✭ 459 (+220.98%)
Mutual labels:  chrome, chromium
Chrome Export Passwords
Show all your chromium passwords in format ready to import in other browser like FireFox
Stars: ✭ 80 (-44.06%)
Mutual labels:  chrome, chromium
Chrome Pak Customizer
a simple command-line tool to pack and unpack pak files in chrome or chromium-based browser
Stars: ✭ 79 (-44.76%)
Mutual labels:  chrome, chromium
Html Pdf Chrome
HTML to PDF converter via Chrome/Chromium
Stars: ✭ 629 (+339.86%)
Mutual labels:  chrome, chromium
Kdeconnect Chrome Extension
A browser extension to send pages and content from your browser to connected KDE Connect devices.
Stars: ✭ 124 (-13.29%)
Mutual labels:  chrome, chromium
Headless Chrome Crawler
Distributed crawler powered by Headless Chrome
Stars: ✭ 5,129 (+3486.71%)
Mutual labels:  chrome, chromium
Web Media Controller
Allows controlling media player on different sites with Media Player widget on your desktop
Stars: ✭ 36 (-74.83%)
Mutual labels:  chrome, chromium
Hstspreload.org
🔒 Chromium's HSTS preload list submission website.
Stars: ✭ 548 (+283.22%)
Mutual labels:  chrome, chromium
Mue
Fast, open and free-to-use new tab page for modern browsers
Stars: ✭ 56 (-60.84%)
Mutual labels:  chrome, chromium
Puppetron
Puppeteer (Headless Chrome Node API)-based rendering solution.
Stars: ✭ 429 (+200%)
Mutual labels:  chrome, chromium
Qzoneexport
QQ空间导出助手,用于备份QQ空间的说说、日志、私密日记、相册、视频、留言板、QQ好友、收藏夹、分享、最近访客为文件,便于迁移与保存
Stars: ✭ 456 (+218.88%)
Mutual labels:  chrome, chromium
Uget Chrome Wrapper
Moved to https://github.com/ugetdm/uget-integrator and https://github.com/ugetdm/uget-extension
Stars: ✭ 74 (-48.25%)
Mutual labels:  chrome, chromium
Chrome Protocol Proxy
Chrome DevTools Protocol Proxy - intelligent proxy for debugging purposes
Stars: ✭ 94 (-34.27%)
Mutual labels:  chrome, chromium

Chrome Remote Control interface and debug protocol and toolkit. Build StatusCoverage Status

NOTE: Tests are currently broken due to an upstream Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=849972

The one-stop-shop for using google-chrome and/or chromium from python. With ChromeController you have complete access to the entire debugging interface you'd get from javascript, but in a language that doesn't make one want to go become a sheep herder instead.

Process lifecycle management, tab management, plus the complete chrome remote debugging interface is exposed through to python.

Automatically updates via automatic code generation by parsing the remote debugging protocol descripion json files.

Quickstart:

import ChromeController

additional_options = ['--user-data-dir=/tmp/x']
with ChromeController.ChromeContext(binary="google-chrome", additional_options=additional_options) as cr:
    
    # Do a blocking navigate to a URL, and get the page content as served by the remote
    # server, with no modification by local javascript (if applicable)
    raw_source = cr.blocking_navigate_and_get_source("http://www.google.com")
    
    # Since the page is now rendered by the blocking navigate, we can
    # get the page source after any javascript has modified it.
    rendered_source = cr.get_rendered_page_source()
    
    # We can get the current browser URL, after any redirects.
    current_url = cr.get_current_url()
    
    # We can get the page title as the browser sees it.
    page_title, page_url = cr.get_page_url_title()
    
    # Or take a screenshot
    # The screenshot is the size of the remote browser's configured viewport,
    # which by default is set to 1024 * 1366. This size can be changed via the
    # Emulation_setVisibleSize(width, height) function if needed.
    png_bytestring = cr.take_screeshot()
    
    
    # We can spoof user-agent headers:
    new_headers = {
                'User-Agent'      : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36,gzip(gfe)', 
                'Accept-Language' : 'en-us, en;q=1.0,fr-ca, fr;q=0.5,pt-br, pt;q=0.5,es;q=0.5', 
                'Accept'          : 'image/png,  text/plain;q=0.8, text/html;q=0.9, application/xhtml+xml, application/xml, */*;q=0.1', 
                'Accept-Encoding' : 'gzip,deflate',
            }
    cr.update_headers(new_headers)
    
    
    # We can extract the cookies from the remote browser.
    # This call returns a list of python http.cookiejar.Cookie cookie
    # objects (the Chrome cookies are converted to python cookies).
    cookie_list = cr.get_cookies()
    
    # We can also set cookies in the remote browser.
    # Again, this interacts with http.cookiejar.Cookie() objects
    # directly.
    cook = http.cookiejar.Cookie(<params>)
    cr.set_cookie(cook)

    # We can create more tabs in the current browser context.
    # Note that these additional tabs are scoped to the same lifetime as the original 
    # chromium object (`cr`), so they will become invalid after leaving the 
    # ChromeContext() context manager.
    tab_2 = cr.new_tab()
    tab_3 = cr.new_tab()

    # At this time, multiple tabs are not thread safe, so they *probably* shouldn't 
    # be accessed concurrently. This *is* something that I'd like to change.

This library makes extensive use of the python logging framework, and logs to the Main.ChromeController.* log path.

Automatic wrapper class creation for the remote interface by parsing the chrome protocol.json file, and dynamic code generation through dynamic AST building. While this is not the most maintainable design, I chose it mostly because I wanted an excuse to learn/experiment with python AST manipulation.

A higher level automation layer is implemented on top of the autogenerated wrapper. Both the higher-level interface, and it's associated documentation are very much a work in process at the moment.

Interface documentation is here:
https://fake-name.github.io/ChromeController/ChromeController.ChromeRemoteDebugInterface.html

All remote methods are wrapped in named functions, with (partial) validation of passed parameter types and return types. Right now, simple parameter type validation is done (e.g. text arguments must be of type string, numeric arguments must be either an int or a float, etc..). However, the compound type arguments (bascally, anything that takes an array or object) are not validated, due to the complexity of properly constructing type validators for their semantics given the architecture (read: writing the validator in raw AST broke my brain).

Tested mostly on python 3.5, 3.6, lightly on 3.8 and 3.7, all on linux. If you are using python 2, please stahp. It works with normal chromium and on windows, but that has only been very lightly used. My test-target is the google-provided chrome binary.

Note that this tool generates and manipulates the AST directly, so it is EXTREMELY sensitive to implementation details. It is probably broken on python > 3.8 or < 3.5.

Transport layer (originally) from https://github.com/minektur/chrome_remote_shell

The library also has a relatively useful CLI interface, principally useful for doing things like fetching pages which have jerberscript-rendered content:

 python3 -m ChromeController --help
Usage: __main__.py [OPTIONS] COMMAND [ARGS]...

  ChromeController

  Usage: python3 -m ChromeController [-s | --silent] [-v | --verbose]
    python3 -m ChromeController fetch <url> [--binary <bin_name>] [--outfile <out_file_name>]
    python3 -m ChromeController update
    python3 -m ChromeController (-h | --help)
    python3 -m ChromeController --version

  Options:
    -s --silent   Suppress all output aside from the fetched content
                  This basically makes ChromeController act like a alternative to curl
    -v --verbose  The opposite of silent. Causes the internal logging to output
                  all traffic over the chromium control interface. VERY noisy.
    --version     Show version.
    fetch         Fetch a specified URL's content, and output it to the console.


Options:
  -v, --verbose  The opposite of silent. Causes the internal logging to output
                 all traffic over the chromium control interface. VERY noisy.
  -s, --silent   Suppress all output aside from the fetched content.
                 This can be used to make ChromeController act like
                 an alternative to curl with proper JS rendering.
  --help         Show this message and exit.

Commands:
  fetch    Fetch a specified URL's content, and output...
  update   Update the generated class
  version  Print the ChromeController Version

License: BSD


Current Usage so far has been basically to find bugs or strangeness in the chromium remote debug interface:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].