whom-integration 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- whom_integration-1.0.0/CHANGELOG.md +40 -0
- whom_integration-1.0.0/LICENSE +21 -0
- whom_integration-1.0.0/MANIFEST.in +21 -0
- whom_integration-1.0.0/PKG-INFO +299 -0
- whom_integration-1.0.0/README.md +250 -0
- whom_integration-1.0.0/app/__init__.py +58 -0
- whom_integration-1.0.0/app/cli.py +162 -0
- whom_integration-1.0.0/app/core.py +198 -0
- whom_integration-1.0.0/app/drivers/__init__.py +10 -0
- whom_integration-1.0.0/app/drivers/base.py +113 -0
- whom_integration-1.0.0/app/drivers/playwright_driver.py +134 -0
- whom_integration-1.0.0/app/drivers/selenium_driver.py +177 -0
- whom_integration-1.0.0/app/exceptions.py +45 -0
- whom_integration-1.0.0/app/systems/__init__.py +10 -0
- whom_integration-1.0.0/app/systems/base.py +195 -0
- whom_integration-1.0.0/app/systems/ecac_system.py +115 -0
- whom_integration-1.0.0/app/systems/pje_system.py +193 -0
- whom_integration-1.0.0/pyproject.toml +154 -0
- whom_integration-1.0.0/requirements.txt +9 -0
- whom_integration-1.0.0/setup.cfg +4 -0
- whom_integration-1.0.0/setup.py +81 -0
- whom_integration-1.0.0/whom_integration.egg-info/PKG-INFO +299 -0
- whom_integration-1.0.0/whom_integration.egg-info/SOURCES.txt +26 -0
- whom_integration-1.0.0/whom_integration.egg-info/dependency_links.txt +1 -0
- whom_integration-1.0.0/whom_integration.egg-info/entry_points.txt +2 -0
- whom_integration-1.0.0/whom_integration.egg-info/not-zip-safe +1 -0
- whom_integration-1.0.0/whom_integration.egg-info/requires.txt +26 -0
- whom_integration-1.0.0/whom_integration.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial project setup
|
|
12
|
+
- Basic documentation structure
|
|
13
|
+
|
|
14
|
+
## [1.0.0] - 2025-08-19
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Initial support for ECAC (Federal Revenue System)
|
|
18
|
+
- Initial support for PJE (Judiciary System)
|
|
19
|
+
- Selenium and Playwright drivers
|
|
20
|
+
- Intelligent proxy system
|
|
21
|
+
- Modular and extensible architecture
|
|
22
|
+
- Complete documentation
|
|
23
|
+
- Session management and authentication
|
|
24
|
+
- Workflow execution system
|
|
25
|
+
- Cookie and JavaScript command handling
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
- **ECAC System**: Integration with Federal Revenue systems using Playwright
|
|
29
|
+
- **PJE System**: Integration with Judiciary systems using Selenium
|
|
30
|
+
- **Multiple Drivers**: Support for both Selenium and Playwright automation
|
|
31
|
+
- **Session Management**: Automatic authentication and connection handling
|
|
32
|
+
- **Workflow System**: Predefined and customizable workflow execution
|
|
33
|
+
- **Error Handling**: Robust exception handling and error recovery
|
|
34
|
+
|
|
35
|
+
### Technical Details
|
|
36
|
+
- Python 3.8+ compatibility
|
|
37
|
+
- Type hints support
|
|
38
|
+
- Modular architecture with abstract base classes
|
|
39
|
+
- Context manager support for session handling
|
|
40
|
+
- Comprehensive logging and status reporting
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cleber Castro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include requirements.txt
|
|
4
|
+
include CHANGELOG.md
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
|
|
7
|
+
recursive-include examples *
|
|
8
|
+
recursive-exclude * __pycache__
|
|
9
|
+
recursive-exclude * *.py[co]
|
|
10
|
+
|
|
11
|
+
global-exclude *.pyc
|
|
12
|
+
global-exclude *.pyo
|
|
13
|
+
global-exclude *.pyd
|
|
14
|
+
global-exclude .git*
|
|
15
|
+
global-exclude .DS_Store
|
|
16
|
+
global-exclude .env*
|
|
17
|
+
global-exclude .venv*
|
|
18
|
+
global-exclude venv*
|
|
19
|
+
global-exclude build*
|
|
20
|
+
global-exclude dist*
|
|
21
|
+
global-exclude *.egg-info*
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: whom-integration
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python library for Whom API integration, supporting multiple systems and web automation drivers
|
|
5
|
+
Home-page: https://github.com/doc9/whom-integration
|
|
6
|
+
Author: Doc9
|
|
7
|
+
Author-email: Doc9 <cloud@doc9.com.br>
|
|
8
|
+
Maintainer-email: Doc9 <cloud@doc9.com.br>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/doc9/whom-integration
|
|
11
|
+
Project-URL: Documentation, https://github.com/doc9/whom-integration#readme
|
|
12
|
+
Project-URL: Repository, https://github.com/doc9/whom-integration
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/doc9/whom-integration/issues
|
|
14
|
+
Project-URL: Changelog, https://github.com/doc9/whom-integration/blob/main/CHANGELOG.md
|
|
15
|
+
Keywords: whom,api,integration,automation,selenium,playwright,ecac,pje,receita-federal,judiciary,web-scraping,browser-automation
|
|
16
|
+
Classifier: Development Status :: 4 - Beta
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pre-commit>=2.20.0; extra == "dev"
|
|
32
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
33
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
34
|
+
Provides-Extra: selenium
|
|
35
|
+
Requires-Dist: selenium>=4.0.0; extra == "selenium"
|
|
36
|
+
Requires-Dist: webdriver-manager>=3.8.0; extra == "selenium"
|
|
37
|
+
Provides-Extra: playwright
|
|
38
|
+
Requires-Dist: playwright>=1.30.0; extra == "playwright"
|
|
39
|
+
Requires-Dist: patchright>=0.1.0; extra == "playwright"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: selenium>=4.0.0; extra == "all"
|
|
42
|
+
Requires-Dist: webdriver-manager>=3.8.0; extra == "all"
|
|
43
|
+
Requires-Dist: playwright>=1.30.0; extra == "all"
|
|
44
|
+
Requires-Dist: patchright>=0.1.0; extra == "all"
|
|
45
|
+
Dynamic: author
|
|
46
|
+
Dynamic: home-page
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
Dynamic: requires-python
|
|
49
|
+
|
|
50
|
+
# Whom Integration Library
|
|
51
|
+
|
|
52
|
+
Versatile Python library for Whom API integration, supporting multiple systems and web automation drivers.
|
|
53
|
+
|
|
54
|
+
## 🚀 Features
|
|
55
|
+
|
|
56
|
+
- **🔌 Multiple Drivers**: Support for Selenium and Playwright
|
|
57
|
+
- **🎯 Extensible Systems**: Modular architecture for different systems
|
|
58
|
+
- **⚡ Easy to Use**: Simple and intuitive API
|
|
59
|
+
- **🛡️ Error Handling**: Custom and robust exceptions
|
|
60
|
+
- **📚 Well Documented**: Complete examples and documentation
|
|
61
|
+
|
|
62
|
+
## 📦 Installation
|
|
63
|
+
|
|
64
|
+
### Basic Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install whom-integration
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Installation with Specific Drivers
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Install with Selenium support
|
|
74
|
+
pip install "whom-integration[selenium]"
|
|
75
|
+
|
|
76
|
+
# Install with Playwright support
|
|
77
|
+
pip install "whom-integration[playwright]"
|
|
78
|
+
|
|
79
|
+
# Install with all drivers
|
|
80
|
+
pip install "whom-integration[all]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Development Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Install with development tools
|
|
87
|
+
pip install "whom-integration[dev]"
|
|
88
|
+
|
|
89
|
+
# Manual installation from source
|
|
90
|
+
git clone https://github.com/doc9/whom-integration.git
|
|
91
|
+
cd whom-integration
|
|
92
|
+
pip install -e .
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Driver Setup
|
|
96
|
+
|
|
97
|
+
After installation, you may need to set up the drivers:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# For Playwright
|
|
101
|
+
playwright install chromium
|
|
102
|
+
|
|
103
|
+
# For Selenium
|
|
104
|
+
# ChromeDriver is usually auto-installed via webdriver-manager
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 🎯 Quick Start
|
|
108
|
+
|
|
109
|
+
### Command Line Interface
|
|
110
|
+
|
|
111
|
+
The library includes a CLI for quick testing:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Test ECAC with Playwright
|
|
115
|
+
whom-integration --system ecac --driver playwright --token YOUR_TOKEN --extension YOUR_EXTENSION
|
|
116
|
+
|
|
117
|
+
# Test PJE with Selenium
|
|
118
|
+
whom-integration --system pje --driver selenium --token YOUR_TOKEN --extension YOUR_EXTENSION
|
|
119
|
+
|
|
120
|
+
# Show help
|
|
121
|
+
whom-integration --help
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Example with Selenium
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from whom_integration import WhomClient, ECACSystem, SeleniumDriver
|
|
128
|
+
|
|
129
|
+
# Configure client
|
|
130
|
+
client = WhomClient(token="your_token", extension_id="your_extension_id")
|
|
131
|
+
|
|
132
|
+
# Create session
|
|
133
|
+
with client.create_session(ECACSystem, SeleniumDriver) as session:
|
|
134
|
+
# Authenticate and connect
|
|
135
|
+
session.authenticate_and_connect()
|
|
136
|
+
|
|
137
|
+
# Execute workflow
|
|
138
|
+
result = session.execute_workflow("default")
|
|
139
|
+
|
|
140
|
+
print(f"Success: {result['success']}")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Example with Playwright
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from whom_integration import WhomClient, ECACSystem, PlaywrightDriver
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
client = WhomClient(token="your_token", extension_id="your_extension_id")
|
|
150
|
+
|
|
151
|
+
with client.create_session(ECACSystem, PlaywrightDriver) as session:
|
|
152
|
+
session.authenticate_and_connect()
|
|
153
|
+
result = session.execute_workflow("default")
|
|
154
|
+
print(f"Success: {result['success']}")
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 🏗️ Architecture
|
|
159
|
+
|
|
160
|
+
### Main Components
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
whom_integration/
|
|
164
|
+
├── __init__.py # Main interface
|
|
165
|
+
├── core.py # Client and session
|
|
166
|
+
├── drivers/ # Automation drivers
|
|
167
|
+
│ ├── base.py # Abstract base class
|
|
168
|
+
│ ├── selenium_driver.py
|
|
169
|
+
│ └── playwright_driver.py
|
|
170
|
+
├── systems/ # Supported systems
|
|
171
|
+
│ ├── base.py # Abstract base class
|
|
172
|
+
│ └── ecac_system.py # ECAC system
|
|
173
|
+
│ └── pje_system.py # PJE system
|
|
174
|
+
└── exceptions.py # Custom exceptions
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Workflow
|
|
178
|
+
|
|
179
|
+
1. **Whom Client**: Manages API authentication
|
|
180
|
+
2. **Driver**: Controls the browser (Selenium/Playwright)
|
|
181
|
+
3. **System**: Implements target system specific logic
|
|
182
|
+
4. **Session**: Orchestrates the entire process
|
|
183
|
+
|
|
184
|
+
## 🔧 Configuration
|
|
185
|
+
|
|
186
|
+
### Basic Configuration
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from whom_integration import WhomClient
|
|
190
|
+
|
|
191
|
+
client = WhomClient(
|
|
192
|
+
token="your_token_here",
|
|
193
|
+
extension_id="your_extension_id_here",
|
|
194
|
+
base_url="https://cloud.doc9.com.br" # Optional
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Driver Configuration
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
# Selenium
|
|
202
|
+
session = client.create_session(
|
|
203
|
+
ECACSystem,
|
|
204
|
+
SeleniumDriver,
|
|
205
|
+
headless=False,
|
|
206
|
+
window_size=(1920, 1080)
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# Playwright
|
|
210
|
+
session = client.create_session(
|
|
211
|
+
ECACSystem,
|
|
212
|
+
PlaywrightDriver,
|
|
213
|
+
headless=False,
|
|
214
|
+
viewport={'width': 1920, 'height': 1080}
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 🎯 **Direct Access to Session Objects**
|
|
219
|
+
|
|
220
|
+
When you create a session, you have direct access to all available objects and methods:
|
|
221
|
+
|
|
222
|
+
### 📱 **Driver (Browser)**
|
|
223
|
+
```python
|
|
224
|
+
# Direct access to configured driver
|
|
225
|
+
session.driver.navigate("https://example.com")
|
|
226
|
+
session.driver.execute_script("alert('Hello!')")
|
|
227
|
+
session.driver.click_element("#button")
|
|
228
|
+
session.driver.wait_for_element(".class", timeout=10)
|
|
229
|
+
session.driver.get_page_title()
|
|
230
|
+
session.driver.get_current_url()
|
|
231
|
+
|
|
232
|
+
# For Playwright - direct access to page object
|
|
233
|
+
if hasattr(session.driver, 'page'):
|
|
234
|
+
session.driver.page.fill("#input", "text")
|
|
235
|
+
session.driver.page.screenshot(path="screenshot.png")
|
|
236
|
+
session.driver.page.pdf(path="page.pdf")
|
|
237
|
+
|
|
238
|
+
# For Selenium - direct access to driver object
|
|
239
|
+
if hasattr(session.driver, 'driver'):
|
|
240
|
+
session.driver.driver.find_element(By.ID, "element")
|
|
241
|
+
session.driver.driver.execute_script("return document.title")
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 🖥️ **System Data**
|
|
245
|
+
```python
|
|
246
|
+
# System specific methods
|
|
247
|
+
redirect_url = session.system.get_redirect_url()
|
|
248
|
+
target_url = session.system.get_target_url()
|
|
249
|
+
js_commands = session.system.get_js_commands()
|
|
250
|
+
cookies = session.system.get_cookies()
|
|
251
|
+
|
|
252
|
+
# Execute custom workflows
|
|
253
|
+
result = session.system.execute_workflow("custom_workflow", param1="value")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 📊 **Session Data**
|
|
257
|
+
```python
|
|
258
|
+
# Direct access to data returned by API
|
|
259
|
+
session_data = session.session_data
|
|
260
|
+
|
|
261
|
+
# Session cookies
|
|
262
|
+
cookies = session_data.get('cookies', [])
|
|
263
|
+
|
|
264
|
+
# Important URLs
|
|
265
|
+
entry_point = session_data.get('entry_point')
|
|
266
|
+
redirect_url = session_data.get('redirect')
|
|
267
|
+
target_url = session_data.get('url')
|
|
268
|
+
|
|
269
|
+
# JavaScript commands for execution
|
|
270
|
+
js_commands = session_data.get('js', [])
|
|
271
|
+
|
|
272
|
+
# Allowed domains
|
|
273
|
+
allowed_domains = session_data.get('domains', [])
|
|
274
|
+
|
|
275
|
+
# Elements to hide
|
|
276
|
+
hidden_elements = session_data.get('elements_to_hidden', {})
|
|
277
|
+
|
|
278
|
+
# Extra data
|
|
279
|
+
extra_data = session_data.get('extra', {})
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## 🎯 Supported Systems
|
|
283
|
+
|
|
284
|
+
### 📊 **Driver Compatibility Table**
|
|
285
|
+
|
|
286
|
+
| System | Selenium | Playwright | Notes |
|
|
287
|
+
|---------|----------|------------|-------|
|
|
288
|
+
| **ECAC** | ❌ | ✅ | Federal Revenue System - only works with Playwright |
|
|
289
|
+
| **PJE** | ✅ | ❌ | Judiciary System - only works with Selenium |
|
|
290
|
+
|
|
291
|
+
## 🔄 Changelog
|
|
292
|
+
|
|
293
|
+
### v1.0.0
|
|
294
|
+
- ✅ Initial support for ECAC
|
|
295
|
+
- ✅ Initial support for PJE
|
|
296
|
+
- ✅ Selenium and Playwright drivers
|
|
297
|
+
- ✅ Intelligent proxy system
|
|
298
|
+
- ✅ Modular and extensible architecture
|
|
299
|
+
- ✅ Complete documentation
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Whom Integration Library
|
|
2
|
+
|
|
3
|
+
Versatile Python library for Whom API integration, supporting multiple systems and web automation drivers.
|
|
4
|
+
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **🔌 Multiple Drivers**: Support for Selenium and Playwright
|
|
8
|
+
- **🎯 Extensible Systems**: Modular architecture for different systems
|
|
9
|
+
- **⚡ Easy to Use**: Simple and intuitive API
|
|
10
|
+
- **🛡️ Error Handling**: Custom and robust exceptions
|
|
11
|
+
- **📚 Well Documented**: Complete examples and documentation
|
|
12
|
+
|
|
13
|
+
## 📦 Installation
|
|
14
|
+
|
|
15
|
+
### Basic Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install whom-integration
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Installation with Specific Drivers
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install with Selenium support
|
|
25
|
+
pip install "whom-integration[selenium]"
|
|
26
|
+
|
|
27
|
+
# Install with Playwright support
|
|
28
|
+
pip install "whom-integration[playwright]"
|
|
29
|
+
|
|
30
|
+
# Install with all drivers
|
|
31
|
+
pip install "whom-integration[all]"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Development Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install with development tools
|
|
38
|
+
pip install "whom-integration[dev]"
|
|
39
|
+
|
|
40
|
+
# Manual installation from source
|
|
41
|
+
git clone https://github.com/doc9/whom-integration.git
|
|
42
|
+
cd whom-integration
|
|
43
|
+
pip install -e .
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Driver Setup
|
|
47
|
+
|
|
48
|
+
After installation, you may need to set up the drivers:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# For Playwright
|
|
52
|
+
playwright install chromium
|
|
53
|
+
|
|
54
|
+
# For Selenium
|
|
55
|
+
# ChromeDriver is usually auto-installed via webdriver-manager
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 🎯 Quick Start
|
|
59
|
+
|
|
60
|
+
### Command Line Interface
|
|
61
|
+
|
|
62
|
+
The library includes a CLI for quick testing:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Test ECAC with Playwright
|
|
66
|
+
whom-integration --system ecac --driver playwright --token YOUR_TOKEN --extension YOUR_EXTENSION
|
|
67
|
+
|
|
68
|
+
# Test PJE with Selenium
|
|
69
|
+
whom-integration --system pje --driver selenium --token YOUR_TOKEN --extension YOUR_EXTENSION
|
|
70
|
+
|
|
71
|
+
# Show help
|
|
72
|
+
whom-integration --help
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Example with Selenium
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from whom_integration import WhomClient, ECACSystem, SeleniumDriver
|
|
79
|
+
|
|
80
|
+
# Configure client
|
|
81
|
+
client = WhomClient(token="your_token", extension_id="your_extension_id")
|
|
82
|
+
|
|
83
|
+
# Create session
|
|
84
|
+
with client.create_session(ECACSystem, SeleniumDriver) as session:
|
|
85
|
+
# Authenticate and connect
|
|
86
|
+
session.authenticate_and_connect()
|
|
87
|
+
|
|
88
|
+
# Execute workflow
|
|
89
|
+
result = session.execute_workflow("default")
|
|
90
|
+
|
|
91
|
+
print(f"Success: {result['success']}")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Example with Playwright
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from whom_integration import WhomClient, ECACSystem, PlaywrightDriver
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
client = WhomClient(token="your_token", extension_id="your_extension_id")
|
|
101
|
+
|
|
102
|
+
with client.create_session(ECACSystem, PlaywrightDriver) as session:
|
|
103
|
+
session.authenticate_and_connect()
|
|
104
|
+
result = session.execute_workflow("default")
|
|
105
|
+
print(f"Success: {result['success']}")
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 🏗️ Architecture
|
|
110
|
+
|
|
111
|
+
### Main Components
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
whom_integration/
|
|
115
|
+
├── __init__.py # Main interface
|
|
116
|
+
├── core.py # Client and session
|
|
117
|
+
├── drivers/ # Automation drivers
|
|
118
|
+
│ ├── base.py # Abstract base class
|
|
119
|
+
│ ├── selenium_driver.py
|
|
120
|
+
│ └── playwright_driver.py
|
|
121
|
+
├── systems/ # Supported systems
|
|
122
|
+
│ ├── base.py # Abstract base class
|
|
123
|
+
│ └── ecac_system.py # ECAC system
|
|
124
|
+
│ └── pje_system.py # PJE system
|
|
125
|
+
└── exceptions.py # Custom exceptions
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Workflow
|
|
129
|
+
|
|
130
|
+
1. **Whom Client**: Manages API authentication
|
|
131
|
+
2. **Driver**: Controls the browser (Selenium/Playwright)
|
|
132
|
+
3. **System**: Implements target system specific logic
|
|
133
|
+
4. **Session**: Orchestrates the entire process
|
|
134
|
+
|
|
135
|
+
## 🔧 Configuration
|
|
136
|
+
|
|
137
|
+
### Basic Configuration
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from whom_integration import WhomClient
|
|
141
|
+
|
|
142
|
+
client = WhomClient(
|
|
143
|
+
token="your_token_here",
|
|
144
|
+
extension_id="your_extension_id_here",
|
|
145
|
+
base_url="https://cloud.doc9.com.br" # Optional
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Driver Configuration
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
# Selenium
|
|
153
|
+
session = client.create_session(
|
|
154
|
+
ECACSystem,
|
|
155
|
+
SeleniumDriver,
|
|
156
|
+
headless=False,
|
|
157
|
+
window_size=(1920, 1080)
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
# Playwright
|
|
161
|
+
session = client.create_session(
|
|
162
|
+
ECACSystem,
|
|
163
|
+
PlaywrightDriver,
|
|
164
|
+
headless=False,
|
|
165
|
+
viewport={'width': 1920, 'height': 1080}
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## 🎯 **Direct Access to Session Objects**
|
|
170
|
+
|
|
171
|
+
When you create a session, you have direct access to all available objects and methods:
|
|
172
|
+
|
|
173
|
+
### 📱 **Driver (Browser)**
|
|
174
|
+
```python
|
|
175
|
+
# Direct access to configured driver
|
|
176
|
+
session.driver.navigate("https://example.com")
|
|
177
|
+
session.driver.execute_script("alert('Hello!')")
|
|
178
|
+
session.driver.click_element("#button")
|
|
179
|
+
session.driver.wait_for_element(".class", timeout=10)
|
|
180
|
+
session.driver.get_page_title()
|
|
181
|
+
session.driver.get_current_url()
|
|
182
|
+
|
|
183
|
+
# For Playwright - direct access to page object
|
|
184
|
+
if hasattr(session.driver, 'page'):
|
|
185
|
+
session.driver.page.fill("#input", "text")
|
|
186
|
+
session.driver.page.screenshot(path="screenshot.png")
|
|
187
|
+
session.driver.page.pdf(path="page.pdf")
|
|
188
|
+
|
|
189
|
+
# For Selenium - direct access to driver object
|
|
190
|
+
if hasattr(session.driver, 'driver'):
|
|
191
|
+
session.driver.driver.find_element(By.ID, "element")
|
|
192
|
+
session.driver.driver.execute_script("return document.title")
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 🖥️ **System Data**
|
|
196
|
+
```python
|
|
197
|
+
# System specific methods
|
|
198
|
+
redirect_url = session.system.get_redirect_url()
|
|
199
|
+
target_url = session.system.get_target_url()
|
|
200
|
+
js_commands = session.system.get_js_commands()
|
|
201
|
+
cookies = session.system.get_cookies()
|
|
202
|
+
|
|
203
|
+
# Execute custom workflows
|
|
204
|
+
result = session.system.execute_workflow("custom_workflow", param1="value")
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 📊 **Session Data**
|
|
208
|
+
```python
|
|
209
|
+
# Direct access to data returned by API
|
|
210
|
+
session_data = session.session_data
|
|
211
|
+
|
|
212
|
+
# Session cookies
|
|
213
|
+
cookies = session_data.get('cookies', [])
|
|
214
|
+
|
|
215
|
+
# Important URLs
|
|
216
|
+
entry_point = session_data.get('entry_point')
|
|
217
|
+
redirect_url = session_data.get('redirect')
|
|
218
|
+
target_url = session_data.get('url')
|
|
219
|
+
|
|
220
|
+
# JavaScript commands for execution
|
|
221
|
+
js_commands = session_data.get('js', [])
|
|
222
|
+
|
|
223
|
+
# Allowed domains
|
|
224
|
+
allowed_domains = session_data.get('domains', [])
|
|
225
|
+
|
|
226
|
+
# Elements to hide
|
|
227
|
+
hidden_elements = session_data.get('elements_to_hidden', {})
|
|
228
|
+
|
|
229
|
+
# Extra data
|
|
230
|
+
extra_data = session_data.get('extra', {})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 🎯 Supported Systems
|
|
234
|
+
|
|
235
|
+
### 📊 **Driver Compatibility Table**
|
|
236
|
+
|
|
237
|
+
| System | Selenium | Playwright | Notes |
|
|
238
|
+
|---------|----------|------------|-------|
|
|
239
|
+
| **ECAC** | ❌ | ✅ | Federal Revenue System - only works with Playwright |
|
|
240
|
+
| **PJE** | ✅ | ❌ | Judiciary System - only works with Selenium |
|
|
241
|
+
|
|
242
|
+
## 🔄 Changelog
|
|
243
|
+
|
|
244
|
+
### v1.0.0
|
|
245
|
+
- ✅ Initial support for ECAC
|
|
246
|
+
- ✅ Initial support for PJE
|
|
247
|
+
- ✅ Selenium and Playwright drivers
|
|
248
|
+
- ✅ Intelligent proxy system
|
|
249
|
+
- ✅ Modular and extensible architecture
|
|
250
|
+
- ✅ Complete documentation
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Whom Integration Library
|
|
3
|
+
|
|
4
|
+
Versatile Python library for Whom API integration, supporting multiple systems
|
|
5
|
+
and web automation drivers.
|
|
6
|
+
|
|
7
|
+
This library provides a unified interface for integrating with various government
|
|
8
|
+
systems like ECAC (Federal Revenue) and PJE (Judiciary) using different automation
|
|
9
|
+
drivers including Selenium and Playwright.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|
|
13
|
+
__author__ = "Doc9"
|
|
14
|
+
__email__ = "cloud@doc9.com.br"
|
|
15
|
+
__license__ = "MIT"
|
|
16
|
+
__url__ = "https://github.com/doc9/whom-integration"
|
|
17
|
+
|
|
18
|
+
# Core classes
|
|
19
|
+
from .core import WhomClient, WhomSession
|
|
20
|
+
|
|
21
|
+
# Systems
|
|
22
|
+
from .systems.ecac_system import ECACSystem
|
|
23
|
+
from .systems.pje_system import PJESystem
|
|
24
|
+
|
|
25
|
+
# Drivers
|
|
26
|
+
from .drivers.selenium_driver import SeleniumDriver
|
|
27
|
+
from .drivers.playwright_driver import PlaywrightDriver
|
|
28
|
+
|
|
29
|
+
# Exceptions
|
|
30
|
+
from .exceptions import (
|
|
31
|
+
WhomError,
|
|
32
|
+
AuthenticationError,
|
|
33
|
+
ConnectionError,
|
|
34
|
+
WorkflowError,
|
|
35
|
+
DriverError,
|
|
36
|
+
SystemError,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Version info
|
|
40
|
+
__all__ = [
|
|
41
|
+
"__version__",
|
|
42
|
+
"__author__",
|
|
43
|
+
"__email__",
|
|
44
|
+
"__license__",
|
|
45
|
+
"__url__",
|
|
46
|
+
"WhomClient",
|
|
47
|
+
"WhomSession",
|
|
48
|
+
"ECACSystem",
|
|
49
|
+
"PJESystem",
|
|
50
|
+
"SeleniumDriver",
|
|
51
|
+
"PlaywrightDriver",
|
|
52
|
+
"WhomError",
|
|
53
|
+
"AuthenticationError",
|
|
54
|
+
"ConnectionError",
|
|
55
|
+
"WorkflowError",
|
|
56
|
+
"DriverError",
|
|
57
|
+
"SystemError",
|
|
58
|
+
]
|