Sela Network Python SDK - P2P client for browser automation agents
Project description
Sela Browse SDK
Python SDK for browsing the web through the Sela P2P network.
Installation
pip install sela-browse-sdk
Quick Start
import asyncio
from sela_browse_sdk import SelaClient
async def main():
client = await SelaClient.with_api_key("sk_live_xxx")
try:
await client.start()
response = await client.browse("https://example.com", None)
print(f"Title: {response.page.metadata.title}")
finally:
await client.stop()
asyncio.run(main())
Getting an API Key
Contact the Sela team to get your API key (sk_live_xxx).
API Reference
SelaClient
client = await SelaClient.with_api_key("sk_live_xxx")
await client.start()
response = await client.browse(url, options)
await client.stop()
BrowseOptions
from sela_browse_sdk import BrowseOptions
options = BrowseOptions(
timeout_ms=180000, # Request timeout in ms
count=100, # Number of items to fetch
filters={"sort": "newest"}, # Platform-specific filters
)
response = await client.browse(url, options)
Response Structure
response.page.metadata.title # Page title
response.page.page_type # "search", "profile", "feed", etc.
response.page.content # List of extracted items
Each item in response.page.content:
import json
for item in response.page.content:
fields = json.loads(item.fields_json)
print(fields) # {"title": "...", "author": "...", "likes": 123}
Error Handling
from sela_browse_sdk import SelaError
try:
response = await client.browse(url, None)
except SelaError.TimeoutError:
print("Request timed out")
except SelaError.BrowseError as e:
print(f"Browse failed: {e}")
Example
import asyncio
import json
from sela_browse_sdk import SelaClient, BrowseOptions
async def main():
client = await SelaClient.with_api_key("sk_live_xxx")
try:
await client.start()
options = BrowseOptions(
timeout_ms=180000,
count=100,
filters={"sort": "newest", "type": "video"}
)
response = await client.browse(
"https://www.xiaohongshu.com/search_result?keyword=kpop",
options
)
print(f"Title: {response.page.metadata.title}")
print(f"Found: {len(response.page.content)} items")
for item in response.page.content[:5]:
fields = json.loads(item.fields_json)
print(f"- {fields}")
finally:
await client.stop()
asyncio.run(main())
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 sela_browse_sdk-1.0.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: sela_browse_sdk-1.0.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c505e27c082d717484c925c1bda36bbd973f6829d50f845ca445f649cdb12c25
|
|
| MD5 |
f7d98a97fd3aaee0b235646828750c4c
|
|
| BLAKE2b-256 |
86e7e6182436db1f2c408015e3239bd6f847776b45c82c333d8e851e4225fdad
|