AI-powered web browser automation
Project description
Allyson Python SDK
AI-powered web browser automation.
Installation
pip install allyson
After installation, you'll need to install the Playwright browsers:
python -m playwright install
Features
- Simple, intuitive API for browser automation
- AI-powered element selection and interaction
- Support for multiple browsers (Chromium, Firefox, WebKit)
- Asynchronous and synchronous interfaces
- Robust error handling and recovery
- DOM extraction and analysis for AI integration
- Screenshot annotation with element bounding boxes
Quick Start
from allyson import Browser
# Create a browser instance
browser = Browser()
# Navigate to a website
browser.goto("https://example.com")
# Interact with the page
browser.click("Sign in")
browser.fill("Email", "user@example.com")
browser.fill("Password", "password")
browser.click("Submit")
# Take a screenshot
browser.screenshot("login.png")
# Close the browser
browser.close()
Advanced Usage
from allyson import Browser
async def run_automation():
# Use async API with context manager
async with Browser(headless=False) as browser:
await browser.goto("https://example.com")
# Wait for specific element
await browser.wait_for_selector(".content")
# Execute JavaScript
result = await browser.evaluate("document.title")
print(f"Page title: {result}")
# Multiple tabs/pages
new_page = await browser.new_page()
await new_page.goto("https://another-example.com")
# Run the async function
import asyncio
asyncio.run(run_automation())
DOM Extraction and Screenshot Annotation
from allyson import Browser, DOMExtractor
async def extract_and_annotate():
async with Browser(headless=False) as browser:
# Navigate to a website
await browser.goto("https://example.com")
# Create a DOM extractor
dom_extractor = DOMExtractor(browser._page)
# Extract interactive elements
elements = await dom_extractor.extract_interactive_elements()
print(f"Found {len(elements)} interactive elements")
# Take a screenshot with annotations
result = await dom_extractor.screenshot_with_annotations(
path="screenshot.png",
elements=elements,
show_element_ids=True,
box_color="red"
)
print(f"Clean screenshot: {result['clean']}")
print(f"Annotated screenshot: {result['annotated']}")
# Create an element map for AI analysis
map_result = await dom_extractor.screenshot_with_element_map(
path="element_map.png"
)
# The element map contains detailed information about each element
for element in map_result["elementMap"]:
print(f"Element #{element['id']}: {element['elementType']}")
# Run the async function
import asyncio
asyncio.run(extract_and_annotate())
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Automated Publishing
This package uses GitHub Actions for automated testing and publishing to PyPI. The workflow is configured to:
- Run tests on every push to the main branch and on pull requests
- Build the package on every push to the main branch
- Publish to PyPI automatically when:
- A new tag is pushed with the format
v*(e.g., v0.1.0, v1.0.0) - A new GitHub Release is created
- A new tag is pushed with the format
To publish a new version:
- Update the version number in
setup.py - Commit and push your changes to the main branch
- Create and push a new tag:
git tag v0.1.1 git push origin v0.1.1
- The GitHub Action will automatically build and publish the package to PyPI
Note: You need to set up a PyPI API token as a GitHub secret named PYPI_API_TOKEN for the automated publishing to work.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
- 0.1.3 - Added DOM extraction and screenshot annotation features
- 0.1.2 - Updated Description
- 0.1.1 - Test release for GitHub Actions automated publishing
- 0.1.0 - Initial release
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file allyson-0.1.3.tar.gz.
File metadata
- Download URL: allyson-0.1.3.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e970c8b64244d79511f3f56af141b3a360484ed6647365fd79e5746d845796bc
|
|
| MD5 |
dca79635a78820a3ef683bd4fda8990e
|
|
| BLAKE2b-256 |
9437afb96944a3a9d43ef6f27838fc57585551712d29705ab2f18883d86ed0c8
|
File details
Details for the file allyson-0.1.3-py3-none-any.whl.
File metadata
- Download URL: allyson-0.1.3-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d402f3a41e561f97a10a4f2ed775879f5630b5bb5315701d03b95dc716aa25a
|
|
| MD5 |
4f562b1a44cfc593a8f5539ff80eef98
|
|
| BLAKE2b-256 |
e8f544bca371582235ee1bb18a1e4835528151cf6fb1384457f0594fb159003e
|