Python library for Whom API integration, supporting multiple systems and web automation drivers
Project description
Whom Integration Library
Versatile Python library for Whom API integration, supporting multiple systems and web automation drivers.
๐ Features
- ๐ Multiple Drivers: Support for Selenium and Playwright
- ๐ฏ Extensible Systems: Modular architecture for different systems
- โก Easy to Use: Simple and intuitive API
- ๐ก๏ธ Error Handling: Custom and robust exceptions
- ๐ Well Documented: Complete examples and documentation
๐ฆ Installation
Basic Installation
pip install whom-integration
Installation with Specific Drivers
# Install with Selenium support
pip install "whom-integration[selenium]"
# Install with Playwright support
pip install "whom-integration[playwright]"
# Install with all drivers
pip install "whom-integration[all]"
Development Installation
# Install with development tools
pip install "whom-integration[dev]"
# Manual installation from source
git clone https://github.com/doc9/whom-integration.git
cd whom-integration
pip install -e .
Driver Setup
After installation, you may need to set up the drivers:
# For Playwright
playwright install chromium
# For Selenium
# ChromeDriver is usually auto-installed via webdriver-manager
๐ฏ Quick Start
Command Line Interface
The library includes a CLI for quick testing:
# Test ECAC with Playwright
whom-integration --system ecac --driver playwright --token YOUR_TOKEN --extension YOUR_EXTENSION
# Test PJE with Selenium
whom-integration --system pje --driver selenium --token YOUR_TOKEN --extension YOUR_EXTENSION
# Show help
whom-integration --help
Example with Selenium
from whom_integration import WhomClient, ECACSystem, SeleniumDriver
# Configure client
client = WhomClient(token="your_token", extension_id="your_extension_id")
# Create session
with client.create_session(ECACSystem, SeleniumDriver) as session:
# Authenticate and connect
session.authenticate_and_connect()
# Execute workflow
result = session.execute_workflow("default")
print(f"Success: {result['success']}")
Example with Playwright
from whom_integration import WhomClient, ECACSystem, PlaywrightDriver
client = WhomClient(token="your_token", extension_id="your_extension_id")
with client.create_session(ECACSystem, PlaywrightDriver) as session:
session.authenticate_and_connect()
result = session.execute_workflow("default")
print(f"Success: {result['success']}")
๐๏ธ Architecture
Main Components
whom_integration/
โโโ __init__.py # Main interface
โโโ core.py # Client and session
โโโ drivers/ # Automation drivers
โ โโโ base.py # Abstract base class
โ โโโ selenium_driver.py
โ โโโ playwright_driver.py
โโโ systems/ # Supported systems
โ โโโ base.py # Abstract base class
โ โโโ ecac_system.py # ECAC system
โ โโโ pje_system.py # PJE system
โโโ exceptions.py # Custom exceptions
Workflow
- Whom Client: Manages API authentication
- Driver: Controls the browser (Selenium/Playwright)
- System: Implements target system specific logic
- Session: Orchestrates the entire process
๐ง Configuration
Basic Configuration
from whom_integration import WhomClient
client = WhomClient(
token="your_token_here",
extension_id="your_extension_id_here",
base_url="https://cloud.doc9.com.br" # Optional
)
Driver Configuration
# Selenium
session = client.create_session(
ECACSystem,
SeleniumDriver,
headless=False,
window_size=(1920, 1080)
)
# Playwright
session = client.create_session(
ECACSystem,
PlaywrightDriver,
headless=False,
viewport={'width': 1920, 'height': 1080}
)
๐ฏ Direct Access to Session Objects
When you create a session, you have direct access to all available objects and methods:
๐ฑ Driver (Browser)
# Direct access to configured driver
session.driver.navigate("https://example.com")
session.driver.execute_script("alert('Hello!')")
session.driver.click_element("#button")
session.driver.wait_for_element(".class", timeout=10)
session.driver.get_page_title()
session.driver.get_current_url()
# For Playwright - direct access to page object
if hasattr(session.driver, 'page'):
session.driver.page.fill("#input", "text")
session.driver.page.screenshot(path="screenshot.png")
session.driver.page.pdf(path="page.pdf")
# For Selenium - direct access to driver object
if hasattr(session.driver, 'driver'):
session.driver.driver.find_element(By.ID, "element")
session.driver.driver.execute_script("return document.title")
๐ฅ๏ธ System Data
# System specific methods
redirect_url = session.system.get_redirect_url()
target_url = session.system.get_target_url()
js_commands = session.system.get_js_commands()
cookies = session.system.get_cookies()
# Execute custom workflows
result = session.system.execute_workflow("custom_workflow", param1="value")
๐ Session Data
# Direct access to data returned by API
session_data = session.session_data
# Session cookies
cookies = session_data.get('cookies', [])
# Important URLs
entry_point = session_data.get('entry_point')
redirect_url = session_data.get('redirect')
target_url = session_data.get('url')
# JavaScript commands for execution
js_commands = session_data.get('js', [])
# Allowed domains
allowed_domains = session_data.get('domains', [])
# Elements to hide
hidden_elements = session_data.get('elements_to_hidden', {})
# Extra data
extra_data = session_data.get('extra', {})
๐ฏ Supported Systems
๐ Driver Compatibility Table
| System | Selenium | Playwright | Notes |
|---|---|---|---|
| ECAC | โ | โ | Federal Revenue System - only works with Playwright |
| PJE | โ | โ | Judiciary System - only works with Selenium |
๐ Changelog
v1.0.0
- โ Initial support for ECAC
- โ Initial support for PJE
- โ Selenium and Playwright drivers
- โ Intelligent proxy system
- โ Modular and extensible architecture
- โ Complete documentation
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 whom_integration-1.0.0.tar.gz.
File metadata
- Download URL: whom_integration-1.0.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a5643cea2e5481d7d9d033378edffd413a56f82011de028208f46a69026e733
|
|
| MD5 |
e6d216a6a498a7d219d32ca08c5ee399
|
|
| BLAKE2b-256 |
060a667152c7038618ff8806124327df3a84c17ce6bf0b0cf2a092822afa2390
|
File details
Details for the file whom_integration-1.0.0-py3-none-any.whl.
File metadata
- Download URL: whom_integration-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db0dffe9a084cdc0b6532faafcb3dbd902dd3910a0b64ae42eb3c37e3f68cb01
|
|
| MD5 |
c3f4fa35382797f6c078bc33742705c4
|
|
| BLAKE2b-256 |
ff0cd371f1c990ae635f290058f5d43a239dd6ae83e45bfbb33b3b9463be93c7
|