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:

from browsinator import Browser
Browser.start() # Start Chrome or ...
Browser.start_brave() # Start Brave
browser = Browser()

Navigate to a URL

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

Run JavaScript

result = browser.run_script("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()

Run raw debug methods

For example calling Network.getResponseBody with a specific request ID:

result = browser.send_command("Network.getResponseBody", {"requestId": 1})
print(f"Response body: {result}")

Simulate user input

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

Close the browser

browser.close()

Custom Chrome startup

You can also customize the Chrome startup:

# Start Chrome with custom options
Browser.start(
    path="/path/to/chrome",  # Custom Chrome executable path
    minimized=False,         # Start Chrome in normal window (not minimized)
    debug_port=9223          # Use a custom debugging port
)
browser = Browser(debug_port=9222)

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.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

browsinator-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file browsinator-0.1.2.tar.gz.

File metadata

  • Download URL: browsinator-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for browsinator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3e1adfc174eb6ae4e5b73dc6581411801dd8ac9babcbb52b3c16575e9ebe054a
MD5 06c470f95418367a2118425be39da3e6
BLAKE2b-256 1423f0125d5000587f8e6ff09fe66b0fc725a37d6d8bcbdd8c1246fc5577dbe9

See more details on using hashes here.

File details

Details for the file browsinator-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: browsinator-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for browsinator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ba3755acbb3dc5c8d426f2334447636125b055b377b700c8a989b516c1839d6
MD5 a0b4f1c71ba3bfacd2384638b832f63e
BLAKE2b-256 7de4d940638b9d0716a3eff7c2534286538e141f38cf06e5e27b91f9a44434a4

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