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
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
browsinator-0.1.0.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for browsinator-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c8f8a2a9000c8bb8f76a135a3f81bb54d138cf7d1bf27f03805ff72fdbe0066 |
|
MD5 | de0027b54c2d0f838651d1f778d20734 |
|
BLAKE2b-256 | c2caf6ebd5187f10b98205b15b56611e06d0ea7b5a3700492a34483296fcbc9b |