browserfabric 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.
- browserfabric-1.0.0/PKG-INFO +134 -0
- browserfabric-1.0.0/README.md +103 -0
- browserfabric-1.0.0/pyproject.toml +61 -0
- browserfabric-1.0.0/setup.cfg +4 -0
- browserfabric-1.0.0/src/browserfabric/__init__.py +38 -0
- browserfabric-1.0.0/src/browserfabric/client.py +646 -0
- browserfabric-1.0.0/src/browserfabric.egg-info/PKG-INFO +134 -0
- browserfabric-1.0.0/src/browserfabric.egg-info/SOURCES.txt +10 -0
- browserfabric-1.0.0/src/browserfabric.egg-info/dependency_links.txt +1 -0
- browserfabric-1.0.0/src/browserfabric.egg-info/requires.txt +8 -0
- browserfabric-1.0.0/src/browserfabric.egg-info/top_level.txt +1 -0
- browserfabric-1.0.0/tests/test_simple_client.py +331 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: browserfabric
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: BrowserFabric Python SDK - Client library for BrowserFabric browser automation API
|
|
5
|
+
Author-email: Raphael Shu <raphael@uaca.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/acenta-ai/remote_browser
|
|
8
|
+
Project-URL: Documentation, https://browserfabric.com/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/acenta-ai/remote_browser
|
|
10
|
+
Project-URL: Issues, https://github.com/acenta-ai/remote_browser/issues
|
|
11
|
+
Keywords: browser,automation,api,web,crawling,sdk,client,playwright,cdp,headless
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: httpx>=0.25.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
28
|
+
Requires-Dist: black>=23.9.0; extra == "dev"
|
|
29
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
30
|
+
Requires-Dist: mypy>=1.6.0; extra == "dev"
|
|
31
|
+
|
|
32
|
+
# BrowserFabric
|
|
33
|
+
|
|
34
|
+
Python SDK for **BrowserFabric** — cloud browser automation API with persistent sessions and CDP access.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install browserfabric
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import browserfabric
|
|
46
|
+
import asyncio
|
|
47
|
+
|
|
48
|
+
async def main():
|
|
49
|
+
async with browserfabric.browser() as session:
|
|
50
|
+
await session.navigate("https://example.com")
|
|
51
|
+
await session.click("a")
|
|
52
|
+
await session.screenshot("result.png")
|
|
53
|
+
|
|
54
|
+
asyncio.run(main())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Authentication
|
|
58
|
+
|
|
59
|
+
Set your API key as an environment variable or pass it directly:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Via environment variable
|
|
63
|
+
export BROWSERFABRIC_API_KEY=bf_your_key_here
|
|
64
|
+
|
|
65
|
+
# Or pass directly
|
|
66
|
+
async with browserfabric.browser(api_key="bf_...") as session:
|
|
67
|
+
...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Persistent Sessions
|
|
71
|
+
|
|
72
|
+
Save and restore browser state (cookies, localStorage) across sessions:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
# Save state on close
|
|
76
|
+
async with browserfabric.browser(persist=True) as session:
|
|
77
|
+
await session.navigate("https://app.example.com/login")
|
|
78
|
+
await session.type("#email", "user@example.com")
|
|
79
|
+
await session.type("#password", "secret")
|
|
80
|
+
await session.click("#submit")
|
|
81
|
+
ctx = await session.save_context("my-app-login")
|
|
82
|
+
|
|
83
|
+
# Restore later
|
|
84
|
+
async with browserfabric.browser(context_id=ctx["context_id"]) as session:
|
|
85
|
+
# Already logged in
|
|
86
|
+
await session.navigate("https://app.example.com/dashboard")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## CDP WebSocket
|
|
90
|
+
|
|
91
|
+
Connect with Playwright directly for full browser control:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from playwright.async_api import async_playwright
|
|
95
|
+
|
|
96
|
+
# Get the CDP WebSocket URL from session info
|
|
97
|
+
info = await session.session_info()
|
|
98
|
+
ws_url = info["ws_url"]
|
|
99
|
+
|
|
100
|
+
# Connect with Playwright
|
|
101
|
+
pw = await async_playwright().start()
|
|
102
|
+
browser = await pw.chromium.connect_over_cdp(ws_url)
|
|
103
|
+
page = browser.contexts[0].pages[0]
|
|
104
|
+
await page.goto("https://example.com")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Available Methods
|
|
108
|
+
|
|
109
|
+
| Method | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `navigate(url)` | Go to a URL |
|
|
112
|
+
| `click(selector)` | Click an element |
|
|
113
|
+
| `type(selector, text)` | Type into an input |
|
|
114
|
+
| `find(selector)` | Find elements |
|
|
115
|
+
| `screenshot(filename)` | Take a screenshot |
|
|
116
|
+
| `observe()` | Get interactive DOM elements |
|
|
117
|
+
| `snapshot()` | Get accessibility tree |
|
|
118
|
+
| `page_info()` | Get page URL and title |
|
|
119
|
+
| `session_info()` | Get session metadata + CDP URL |
|
|
120
|
+
| `save_context(name)` | Save browser state |
|
|
121
|
+
| `close()` | Close the session |
|
|
122
|
+
|
|
123
|
+
## Self-Hosted
|
|
124
|
+
|
|
125
|
+
Point to your own BrowserFabric instance:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
async with browserfabric.browser(base_url="http://your-server:9000") as session:
|
|
129
|
+
...
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# BrowserFabric
|
|
2
|
+
|
|
3
|
+
Python SDK for **BrowserFabric** — cloud browser automation API with persistent sessions and CDP access.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install browserfabric
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import browserfabric
|
|
15
|
+
import asyncio
|
|
16
|
+
|
|
17
|
+
async def main():
|
|
18
|
+
async with browserfabric.browser() as session:
|
|
19
|
+
await session.navigate("https://example.com")
|
|
20
|
+
await session.click("a")
|
|
21
|
+
await session.screenshot("result.png")
|
|
22
|
+
|
|
23
|
+
asyncio.run(main())
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Authentication
|
|
27
|
+
|
|
28
|
+
Set your API key as an environment variable or pass it directly:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
# Via environment variable
|
|
32
|
+
export BROWSERFABRIC_API_KEY=bf_your_key_here
|
|
33
|
+
|
|
34
|
+
# Or pass directly
|
|
35
|
+
async with browserfabric.browser(api_key="bf_...") as session:
|
|
36
|
+
...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Persistent Sessions
|
|
40
|
+
|
|
41
|
+
Save and restore browser state (cookies, localStorage) across sessions:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
# Save state on close
|
|
45
|
+
async with browserfabric.browser(persist=True) as session:
|
|
46
|
+
await session.navigate("https://app.example.com/login")
|
|
47
|
+
await session.type("#email", "user@example.com")
|
|
48
|
+
await session.type("#password", "secret")
|
|
49
|
+
await session.click("#submit")
|
|
50
|
+
ctx = await session.save_context("my-app-login")
|
|
51
|
+
|
|
52
|
+
# Restore later
|
|
53
|
+
async with browserfabric.browser(context_id=ctx["context_id"]) as session:
|
|
54
|
+
# Already logged in
|
|
55
|
+
await session.navigate("https://app.example.com/dashboard")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## CDP WebSocket
|
|
59
|
+
|
|
60
|
+
Connect with Playwright directly for full browser control:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from playwright.async_api import async_playwright
|
|
64
|
+
|
|
65
|
+
# Get the CDP WebSocket URL from session info
|
|
66
|
+
info = await session.session_info()
|
|
67
|
+
ws_url = info["ws_url"]
|
|
68
|
+
|
|
69
|
+
# Connect with Playwright
|
|
70
|
+
pw = await async_playwright().start()
|
|
71
|
+
browser = await pw.chromium.connect_over_cdp(ws_url)
|
|
72
|
+
page = browser.contexts[0].pages[0]
|
|
73
|
+
await page.goto("https://example.com")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Available Methods
|
|
77
|
+
|
|
78
|
+
| Method | Description |
|
|
79
|
+
|--------|-------------|
|
|
80
|
+
| `navigate(url)` | Go to a URL |
|
|
81
|
+
| `click(selector)` | Click an element |
|
|
82
|
+
| `type(selector, text)` | Type into an input |
|
|
83
|
+
| `find(selector)` | Find elements |
|
|
84
|
+
| `screenshot(filename)` | Take a screenshot |
|
|
85
|
+
| `observe()` | Get interactive DOM elements |
|
|
86
|
+
| `snapshot()` | Get accessibility tree |
|
|
87
|
+
| `page_info()` | Get page URL and title |
|
|
88
|
+
| `session_info()` | Get session metadata + CDP URL |
|
|
89
|
+
| `save_context(name)` | Save browser state |
|
|
90
|
+
| `close()` | Close the session |
|
|
91
|
+
|
|
92
|
+
## Self-Hosted
|
|
93
|
+
|
|
94
|
+
Point to your own BrowserFabric instance:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
async with browserfabric.browser(base_url="http://your-server:9000") as session:
|
|
98
|
+
...
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "browserfabric"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "BrowserFabric Python SDK - Client library for BrowserFabric browser automation API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Raphael Shu", email = "raphael@uaca.com"}
|
|
13
|
+
]
|
|
14
|
+
keywords = ["browser", "automation", "api", "web", "crawling", "sdk", "client", "playwright", "cdp", "headless"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"Topic :: Internet :: WWW/HTTP :: Browsers",
|
|
26
|
+
]
|
|
27
|
+
requires-python = ">=3.9"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"httpx>=0.25.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pytest>=7.4.0",
|
|
35
|
+
"pytest-asyncio>=0.21.0",
|
|
36
|
+
"black>=23.9.0",
|
|
37
|
+
"isort>=5.12.0",
|
|
38
|
+
"mypy>=1.6.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/acenta-ai/remote_browser"
|
|
43
|
+
Documentation = "https://browserfabric.com/docs"
|
|
44
|
+
Repository = "https://github.com/acenta-ai/remote_browser"
|
|
45
|
+
Issues = "https://github.com/acenta-ai/remote_browser/issues"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-dir]
|
|
51
|
+
"" = "src"
|
|
52
|
+
|
|
53
|
+
[tool.black]
|
|
54
|
+
line-length = 88
|
|
55
|
+
target-version = ['py39']
|
|
56
|
+
include = '\.pyi?$'
|
|
57
|
+
|
|
58
|
+
[tool.isort]
|
|
59
|
+
profile = "black"
|
|
60
|
+
multi_line_output = 3
|
|
61
|
+
line_length = 88
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
browserfabric - Python SDK for BrowserFabric API
|
|
3
|
+
|
|
4
|
+
Simple Usage:
|
|
5
|
+
import browserfabric
|
|
6
|
+
|
|
7
|
+
# Super simple interface
|
|
8
|
+
mcp = browserfabric.MCP("browseruse")
|
|
9
|
+
session = await mcp.create_session()
|
|
10
|
+
await session.navigate("https://example.com")
|
|
11
|
+
await session.screenshot("page.png")
|
|
12
|
+
|
|
13
|
+
# Or even simpler with context manager
|
|
14
|
+
async with browserfabric.browser() as browser:
|
|
15
|
+
await browser.navigate("https://example.com")
|
|
16
|
+
await browser.click("#button")
|
|
17
|
+
await browser.screenshot("result.png")
|
|
18
|
+
|
|
19
|
+
# One-liner screenshot
|
|
20
|
+
await browserfabric.screenshot("https://example.com", "example.png")
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
__version__ = "1.0.0"
|
|
24
|
+
__author__ = "BrowserFabric Contributors"
|
|
25
|
+
__email__ = "info@example.com"
|
|
26
|
+
|
|
27
|
+
# Simple client interface
|
|
28
|
+
from .client import MCP, MCPError, browser, ensure_server_running, screenshot, test_form
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
# Simple client interface
|
|
32
|
+
"MCP",
|
|
33
|
+
"browser",
|
|
34
|
+
"screenshot",
|
|
35
|
+
"test_form",
|
|
36
|
+
"ensure_server_running",
|
|
37
|
+
"MCPError",
|
|
38
|
+
]
|