Skip to main content

A Python library for programmatically controlling and interacting with a web browser using the Chrome DevTools Protocol

Project description

Browsinator

Browsinator is a Python library for programmatically controlling and interacting with a web browser using the Chrome DevTools Protocol.

Installation

To install Browsinator, you'll need Python 3.6 or later. You can install it using pip:

pip install browsinator

Usage

Here's a basic example of how to use Browsinator:

Start Chrome with the following command:

MacOS

open -a "Google Chrome" --args --start-minimized --remote-allow-origins=http://localhost:9222 --user-data-dir=/tmp/dir1 --disable-gpu --remote-debugging-port=9222

Linux

google-chrome --start-minimized --remote-allow-origins=http://localhost:9222 --user-data-dir=/tmp/dir1 --disable-gpu --remote-debugging-port=9222

Windows

start "" "C:\Program Files\Google\Chrome\Application\chrome.exe" --start-minimized --remote-allow-origins=http://localhost:9222 --user-data-dir=/tmp/dir1 --disable-gpu --remote-debugging-port=9222

Then you can use Browsinator to control the browser:

browser = Browser()

Navigate to a URL

browser.load("https://example.com", wait=True)

Run JavaScript

result = browser.run_script_sync_get_result("document.title")
print(f"Page title: {result}")

Monitor network traffic

browser.match_network("api/data", lambda req, res, data: print(f"API data: {data}"))
browser.monitor_network()

Simulate user input

browser.keyboard_type("Hello, World!")
browser.keyboard_press_enter()
browser.mouse_click_selector("#submit-button")

Close the browser

browser.close()

Project details


Download files

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

Source Distribution

browsinator-0.1.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

browsinator-0.1.0-py3-none-any.whl (1.9 kB view hashes)

Uploaded Python 3

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