Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ Quick start examples for Lexmount Python SDK.
- Query the public endpoint catalog through `client.catalog_info()`
- Print available regions, host, and endpoint IPs

### context_basic.py - Context Description Demo
- Create a context with `description`
- Start a `read_write` session with that context
- Print the context display name and ID

### context_list_get.py - Context List/Get Demo
- List contexts and print `display_name`
- Get details for a specific context
- Print `description` when present

### context_fork.py - Context Fork Demo
- Accept an existing source `context_id`
- Fork it into a new context
Expand Down Expand Up @@ -103,6 +113,8 @@ cp .env.example .env
# 4. Run examples
python3 demo.py # Basic demo
python3 light_demo.py # Light browser demo
python3 context_basic.py # Context description demo
python3 context_list_get.py # Context list/get demo
python3 context_fork.py <context_id> # Context fork demo
python3 extension_basic.py # Extension demo
python3 proxy_demo.py # Proxy demo
Expand Down
12 changes: 12 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
- 通过 `client.catalog_info()` 查询 public endpoint catalog
- 打印可用 region、host 和 endpoint IP

### context_basic.py - Context 描述演示
- 创建带 `description` 的 context
- 使用该 context 启动 `read_write` 会话
- 打印 context 展示名称和 ID

### context_list_get.py - Context 列表与详情演示
- 列出 context 并打印 `display_name`
- 获取指定 context 详情
- 存在 `description` 时打印描述

### context_fork.py - Context Fork 演示
- 传入一个已有的 source `context_id`
- 基于 source fork 出新的 context
Expand Down Expand Up @@ -97,6 +107,8 @@ cp .env.example .env
# 4. 运行示例
python3 demo.py # 基础演示
python3 light_demo.py # 轻量浏览器演示
python3 context_basic.py # Context 描述演示
python3 context_list_get.py # Context 列表与详情演示
python3 context_fork.py <context_id> # Context Fork 演示
python3 extension_basic.py # 插件演示
python3 proxy_demo.py # 代理演示
Expand Down
4 changes: 3 additions & 1 deletion context_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ def main():
print(f"\n1. Using existing context ID: {context_id}")
else:
context = client.contexts.create(
description="Quickstart login context",
metadata={
# add your metadata here
}
)
context_id = context.id
print(f"\n1. Created context: {context.display_name} ({context_id})")

with sync_playwright() as playwright:
with client.sessions.create(context={"id": context_id, "mode": "read_write"}) as session:
Expand All @@ -46,7 +48,7 @@ def main():
context = browser.contexts[0]
page = context.pages[0]
page.goto("https://www.baidu.com/")
print(f" ✓ Context created with ID: {context_id}")
print(f" ✓ Session created with context: {context_id}")
input("\n Press Enter to continue...")
except Exception as e:
print(f" ✗ Failed to connect to the remote session: {e}")
Expand Down
8 changes: 7 additions & 1 deletion context_list_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ def list_all_contexts():

for ctx in contexts:
status_icon = "🔒" if ctx.is_locked() else "✅"
print(f"\n {status_icon} Context ID: {ctx.id}")
print(f"\n {status_icon} Context: {ctx.display_name}")
print(f" ID: {ctx.id}")
print(f" Status: {ctx.status}")
if ctx.description:
print(f" Description: {ctx.description}")
if ctx.created_at:
print(f" Created: {ctx.created_at}")
if ctx.updated_at:
Expand All @@ -51,7 +54,10 @@ def get_context_details(context_id: str):

try:
ctx = client.contexts.get(context_id)
print(f" Display Name: {ctx.display_name}")
print(f" Status: {ctx.status}")
if ctx.description:
print(f" Description: {ctx.description}")
if ctx.is_locked():
print(f" 🔒 Locked")
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Lexmount SDK
lexmount==0.5.12
lexmount==0.5.15

# Browser automation
playwright>=1.40.0
Expand Down