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.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for browsinator-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19e3e410494aac9eb8205d4454ef9e4ec39458ec12729844950d8786f089993 |
|
MD5 | d3bf52858ca4254ee1e65f89b8f20fbe |
|
BLAKE2b-256 | 5014f2d251ba670e9260c9ff74fa0c41ce80d147c0ff47cdc7e53993971ccb09 |