webfuse 0.0.1__py3-none-any.whl
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.
- webfuse/__init__.py +52 -0
- webfuse/async_client.py +186 -0
- webfuse/async_session.py +362 -0
- webfuse/client.py +197 -0
- webfuse/exceptions.py +36 -0
- webfuse/session.py +417 -0
- webfuse-0.0.1.dist-info/METADATA +173 -0
- webfuse-0.0.1.dist-info/RECORD +9 -0
- webfuse-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: webfuse
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python SDK for automating browser sessions via Webfuse
|
|
5
|
+
Project-URL: Homepage, https://webfuse.com
|
|
6
|
+
Project-URL: Documentation, https://docs.webfuse.com/sdk/python
|
|
7
|
+
Project-URL: Repository, https://github.com/webfuse/webfuse-python
|
|
8
|
+
Project-URL: Changelog, https://github.com/webfuse/webfuse-python/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Surfly <support@surfly.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Keywords: automation,browser,rpc,scraping,testing,web,webfuse
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: httpx>=0.24.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Webfuse Python SDK
|
|
37
|
+
|
|
38
|
+
A Python client for automating browser sessions via the Webfuse RPC service.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install webfuse
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from webfuse import WebfuseClient
|
|
50
|
+
|
|
51
|
+
# Initialize the client with your API key
|
|
52
|
+
client = WebfuseClient(api_key="rk_your_api_key")
|
|
53
|
+
|
|
54
|
+
# Create a browser session
|
|
55
|
+
session = client.create_session(space_id="1234")
|
|
56
|
+
|
|
57
|
+
# Automate the browser
|
|
58
|
+
session.goto("https://example.com")
|
|
59
|
+
session.click("#login-button")
|
|
60
|
+
session.type("#username", "user@example.com")
|
|
61
|
+
session.type("#password", "secret123")
|
|
62
|
+
session.click("#submit")
|
|
63
|
+
|
|
64
|
+
# Take a screenshot
|
|
65
|
+
screenshot = session.screenshot()
|
|
66
|
+
with open("result.png", "wb") as f:
|
|
67
|
+
f.write(screenshot)
|
|
68
|
+
|
|
69
|
+
# End the session when done
|
|
70
|
+
session.end()
|
|
71
|
+
|
|
72
|
+
# Don't forget to close the client
|
|
73
|
+
client.close()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Using Context Managers
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from webfuse import WebfuseClient
|
|
80
|
+
|
|
81
|
+
with WebfuseClient(api_key="rk_your_api_key") as client:
|
|
82
|
+
session = client.create_session(space_id="1234")
|
|
83
|
+
session.goto("https://example.com")
|
|
84
|
+
session.click("button.submit")
|
|
85
|
+
session.end()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Async Support
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import asyncio
|
|
92
|
+
from webfuse import AsyncWebfuseClient
|
|
93
|
+
|
|
94
|
+
async def main():
|
|
95
|
+
async with AsyncWebfuseClient(api_key="rk_your_api_key") as client:
|
|
96
|
+
session = await client.create_session(space_id="1234")
|
|
97
|
+
|
|
98
|
+
await session.goto("https://example.com")
|
|
99
|
+
await session.click("#button")
|
|
100
|
+
await session.type("#input", "Hello World")
|
|
101
|
+
|
|
102
|
+
screenshot = await session.screenshot()
|
|
103
|
+
|
|
104
|
+
await session.end()
|
|
105
|
+
|
|
106
|
+
asyncio.run(main())
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Available Methods
|
|
110
|
+
|
|
111
|
+
### Navigation
|
|
112
|
+
|
|
113
|
+
- `session.goto(url, new_tab=False)` - Navigate to a URL
|
|
114
|
+
- `session.open_tab(url)` - Open a new browser tab
|
|
115
|
+
|
|
116
|
+
### Mouse Actions
|
|
117
|
+
|
|
118
|
+
- `session.click(selector)` - Left-click an element
|
|
119
|
+
- `session.right_click(selector)` - Right-click an element
|
|
120
|
+
- `session.middle_click(selector)` - Middle-click an element
|
|
121
|
+
- `session.hover(selector)` - Move mouse to element
|
|
122
|
+
- `session.scroll(selector, amount, direction="vertical")` - Scroll an element
|
|
123
|
+
|
|
124
|
+
### Keyboard Actions
|
|
125
|
+
|
|
126
|
+
- `session.type(selector, text)` - Type text into an input
|
|
127
|
+
- `session.press(selector, key, modifiers=None)` - Press a keyboard key
|
|
128
|
+
|
|
129
|
+
### Screenshots & DOM
|
|
130
|
+
|
|
131
|
+
- `session.screenshot()` - Take a screenshot (returns PNG bytes)
|
|
132
|
+
- `session.dom_snapshot()` - Get text representation of the DOM
|
|
133
|
+
|
|
134
|
+
### Utilities
|
|
135
|
+
|
|
136
|
+
- `session.wait(ms)` - Wait for specified milliseconds
|
|
137
|
+
- `session.get_functions()` - List available automation functions
|
|
138
|
+
|
|
139
|
+
### Session Management
|
|
140
|
+
|
|
141
|
+
- `session.end()` - End the session
|
|
142
|
+
- `session.is_active` - Check if session is still active
|
|
143
|
+
|
|
144
|
+
## Configuration
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
client = WebfuseClient(
|
|
148
|
+
api_key="rk_your_api_key",
|
|
149
|
+
rpc_url="https://rpc.webfuse.com", # Custom RPC URL
|
|
150
|
+
timeout=60.0, # Request timeout in seconds
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Error Handling
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from webfuse import WebfuseClient, WebfuseError, AuthenticationError, AutomationError
|
|
158
|
+
|
|
159
|
+
try:
|
|
160
|
+
with WebfuseClient(api_key="rk_your_api_key") as client:
|
|
161
|
+
session = client.create_session(space_id="1234")
|
|
162
|
+
session.click("#nonexistent-element")
|
|
163
|
+
except AuthenticationError:
|
|
164
|
+
print("Invalid API key")
|
|
165
|
+
except AutomationError as e:
|
|
166
|
+
print(f"Automation failed: {e.message}")
|
|
167
|
+
except WebfuseError as e:
|
|
168
|
+
print(f"Error: {e.message}")
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
webfuse/__init__.py,sha256=evNoJBZ1BVxQTdIcsPEWvdId8Z-52kPFqwEVSRlp6ac,1096
|
|
2
|
+
webfuse/async_client.py,sha256=lXKl6lPG4tzy1e4SXbVJpLetImQIfXGthVf5UQ3nN-0,5470
|
|
3
|
+
webfuse/async_session.py,sha256=ipc846HEeqW_v_lTdJ6qEBpLDWhY2tA4ir77cfhsoIM,10276
|
|
4
|
+
webfuse/client.py,sha256=7XqGOTa2cc7OnQ01NLY8Kpk6c4rJTAXtb66huT9NRHc,5679
|
|
5
|
+
webfuse/exceptions.py,sha256=CVjeZMmJqYngO71fK99l9VxRvWa-2A1DFVXCEFyD_Gw,659
|
|
6
|
+
webfuse/session.py,sha256=mh6ZQpmU4m_Ai2aA-hN_fq74fziMnzJnhixC-cXzKW0,11845
|
|
7
|
+
webfuse-0.0.1.dist-info/METADATA,sha256=e14RO2ppPWQzoh6m3m0TXCodBMnp85FuaE4klYAiCcA,4828
|
|
8
|
+
webfuse-0.0.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
9
|
+
webfuse-0.0.1.dist-info/RECORD,,
|