Skip to main content

Universal Browser Automation for AI - 100% OpenClaw Compatible

Project description

Qianji v2 ๐Ÿš€

CI PyPI version Python 3.10+ License: MIT Code style: black

Universal Browser Automation for AI - 100% OpenClaw Compatible

Qianji is an enterprise-grade browser automation tool designed for AI agents, developers, and automation workflows. It provides a robust HTTP API, CLI tool, and MCP (Model Context Protocol) support.

๐Ÿ“– ไธญๆ–‡ๆ–‡ๆกฃ

โœจ Features

  • ๐ŸŒ HTTP API - RESTful API for any language
  • ๐Ÿ–ฅ๏ธ CLI Tool - Command-line interface with auto-completion
  • ๐Ÿค– MCP Support - Native Model Context Protocol integration
  • ๐Ÿ”„ Multi-Browser - Manage multiple browser instances
  • ๐Ÿ“ธ Smart Snapshots - Element detection with reference IDs
  • ๐Ÿ—‚๏ธ Tab Management - Create, switch, and close tabs
  • ๐Ÿช Storage Management - Cookies, localStorage, sessionStorage
  • ๐Ÿ› Debug Tools - Console logs, network requests, errors
  • ๐Ÿ”’ Enterprise Ready - Structured logging, error handling, tests

๐Ÿš€ Quick Start

Installation

# Install from PyPI
pip install qianji

# Install browser dependencies
playwright install chromium

CLI Usage

# Check server status
qianji status

# Start browser (auto-starts server if not running)
qianji start

# Navigate to a page
qianji navigate https://example.com

# Get page snapshot
qianji snapshot

# Click element (e1 is the reference from snapshot)
qianji click e1

# Type text
qianji type e2 "hello world"

# Take screenshot
qianji screenshot output.png --full-page

# Stop browser
qianji stop

HTTP API Usage

# Navigate
curl -X POST http://localhost:18796/api/v1/navigate \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'

# Get snapshot
curl -X POST http://localhost:18796/api/v1/snapshot

# Click element
curl -X POST http://localhost:18796/api/v1/act/click \
  -H "Content-Type: application/json" \
  -d '{"ref": "e1"}'

Python API Usage

from qianji import BrowserManager
from qianji.models.config import BrowserConfig

# Create configuration
config = BrowserConfig(
    headless=False,
    no_sandbox=False,
)

# Start browser
manager = BrowserManager(config)
await manager.start()

# Get page
page = await manager.get_or_create_page()

# Navigate
await page.goto("https://example.com")

# Take screenshot
await page.screenshot(path="screenshot.png")

# Stop browser
await manager.stop()

๐Ÿ“š Documentation

๐Ÿ—๏ธ Project Structure

qianji/
โ”œโ”€โ”€ qianji/
โ”‚   โ”œโ”€โ”€ core/           # Core browser management
โ”‚   โ”œโ”€โ”€ routes/         # API routes
โ”‚   โ”œโ”€โ”€ models/         # Data models
โ”‚   โ”œโ”€โ”€ utils/          # Utilities
โ”‚   โ”œโ”€โ”€ cli.py          # CLI tool
โ”‚   โ”œโ”€โ”€ server.py       # HTTP server
โ”‚   โ””โ”€โ”€ mcp.py          # MCP support
โ”œโ”€โ”€ tests/              # Test suite
โ”œโ”€โ”€ docs/               # Documentation
โ”œโ”€โ”€ .github/workflows/  # CI/CD
โ””โ”€โ”€ pyproject.toml      # Project config

๐Ÿงช Development

Setup

# Clone repository
git clone https://github.com/hexian2001/qianji.git
cd qianji

# Install development dependencies
cd qianji && pip install -e ".[dev]"
playwright install chromium

# Install pre-commit hooks
pre-commit install

Code Quality

# Format code
black qianji tests

# Run linter
ruff check qianji tests

# Type check
mypy qianji

# Run tests
pytest

# Run with coverage
pytest --cov=qianji --cov-report=html

๐Ÿ”ง Configuration

Environment Variables

Variable Description Default
QIANJI_PORT Server port 18796
QIANJI_HEADLESS Run headless true
QIANJI_NO_SANDBOX Disable sandbox false
QIANJI_IDLE_TIMEOUT Idle timeout (s) 3600
QIANJI_MAX_LIFETIME Max lifetime (s) 3600

CLI Options

# Start server with options
qianji-server --port 18796 --headless=false

# CLI with options
qianji --server http://localhost:18796 status
qianji start --headless --window-size 1920,1080
qianji snapshot --format json

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Made with โค๏ธ for the AI community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qianji-2.0.1.tar.gz (76.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qianji-2.0.1-py3-none-any.whl (71.4 kB view details)

Uploaded Python 3

File details

Details for the file qianji-2.0.1.tar.gz.

File metadata

  • Download URL: qianji-2.0.1.tar.gz
  • Upload date:
  • Size: 76.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qianji-2.0.1.tar.gz
Algorithm Hash digest
SHA256 26f04900384fbee1fb88bc35fbabf15fced70021150aa498c15de4bd24274e2a
MD5 2b705c023f77bb4de6e675321392488b
BLAKE2b-256 bb86422a2fb16975c84ddc3c9ced9b85da0a75841c2da18fe261d05d781fef33

See more details on using hashes here.

File details

Details for the file qianji-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: qianji-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 71.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qianji-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d8a4e99c2cedfb496e11e7550801e9f554b2d97f4f472d9694bcff3615ebeee
MD5 dcdc404c1e0ffeefeb5ae7ab37fedb39
BLAKE2b-256 c1ad995b01938453da2fcf1ef66ee53fab4114f3a28325914e4b64224c91d842

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page