Skip to main content

RPA SDK - 机器人流程自动化软件开发工具包

Project description

RPA SDK

Python Version License Version

RPA SDK 是一个功能强大的机器人流程自动化(RPA)软件开发工具包,专为Python开发者设计。它提供了浏览器自动化、WebSocket通信、数据库操作等核心功能,帮助您快速构建高效的RPA应用程序。

✨ 主要特性

  • 🌐 浏览器自动化: 基于Playwright的现代浏览器自动化支持
  • 🔌 WebSocket通信: 实时双向通信能力
  • 🗄️ 数据库集成: 支持MySQL数据库操作
  • 📊 数据模型: 内置访问、体检、档案等数据模型
  • 🛠️ 丰富工具: 提供字符串处理、文件操作、系统工具等实用功能
  • 📝 完整日志: 支持调试模式和详细日志记录
  • 🎯 易于扩展: 模块化设计,支持自定义任务处理器

📦 安装

使用pip安装

pip install rpa-sdk

从源码安装

git clone https://gitee.com/aitmc/rpa-sdk.git
cd rpa-sdk
pip install -e .

安装浏览器驱动

安装完成后,需要安装Playwright浏览器驱动:

playwright install

🚀 快速开始

基本使用

from rpa_sdk import RPAClient, Logger

# 创建RPA客户端
client = RPAClient()

# 启用调试日志
Logger.setup(debug_mode=True)

# 初始化浏览器
if client.initialize_browser(headless=False):
    Logger.info("浏览器初始化成功")
    
    # 执行自动化任务
    # ...
    
    # 清理资源
    client.cleanup()

使用浏览器管理器

from rpa_sdk import PlaywrightBrowserManager

with PlaywrightBrowserManager() as browser:
    if browser.initialize(headless=False):
        browser.navigate_to("https://example.com")
        # 执行页面操作
        # ...

WebSocket通信

from rpa_sdk import WebSocketClient

def handle_message(data):
    print(f"收到消息: {data}")

# 创建WebSocket客户端
ws_client = WebSocketClient(
    url="ws://localhost:8765",
    message_handler=handle_message
)

# 连接并发送消息
ws_client.connect()
ws_client.send_message("hello", "Hello, Server!")

数据库操作

from rpa_sdk import DatabaseManager

# 获取数据库管理器
db = DatabaseManager()

# 执行查询
results = db.execute_query("SELECT * FROM users WHERE active = 1")
for row in results:
    print(row)

📚 API文档

核心类

RPAClient

主要的RPA客户端类,提供完整的RPA功能。

  • initialize_browser(headless=True): 初始化浏览器
  • login_system(username, password): 系统登录
  • start(): 启动客户端
  • stop(): 停止客户端
  • cleanup(): 清理资源

PlaywrightBrowserManager

浏览器管理器,负责浏览器实例的生命周期管理。

  • initialize(headless=True): 初始化浏览器
  • navigate_to(url): 导航到指定URL
  • login(username, password): 执行登录操作
  • cleanup(): 清理浏览器资源

WebSocketClient

WebSocket客户端,提供实时通信功能。

  • connect(): 连接到WebSocket服务器
  • send_message(action, message, data=None): 发送消息
  • send_result(key_id, rpa_type, rpa_state, rpa_note): 发送执行结果
  • stop(): 停止连接

工具类

Logger

增强的日志记录器。

  • Logger.setup(debug_mode=False, log_file="rpa.log"): 设置日志配置
  • Logger.info(message, extra_data=None): 记录信息日志
  • Logger.warning(message, extra_data=None): 记录警告日志
  • Logger.error(message, exception=None, extra_data=None): 记录错误日志

🔧 配置

环境变量

  • RPA_DEBUG: 设置为true启用调试模式
  • RPA_LOG_FILE: 指定日志文件路径
  • WEBSOCKET_URL: WebSocket服务器地址

配置文件

您可以创建配置文件来自定义RPA客户端的行为:

# config.py
CONFIG = {
    'browser': {
        'headless': True,
        'timeout': 30000,
    },
    'websocket': {
        'url': 'ws://localhost:8765',
        'reconnect_interval': 5,
    },
    'database': {
        'host': 'localhost',
        'port': 3306,
        'user': 'root',
        'password': 'password',
        'database': 'rpa_db',
    }
}

🎯 使用场景

  • Web自动化测试: 自动化网页操作和测试
  • 数据采集: 从网站批量采集数据
  • 业务流程自动化: 自动化重复性业务操作
  • 系统集成: 连接不同系统进行数据交换
  • 监控和报告: 自动生成报告和监控系统状态

🤝 贡献

欢迎贡献代码!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 创建Pull Request

📄 许可证

本项目采用MIT许可证 - 查看 LICENSE 文件了解详情。

📞 支持

🔄 更新日志

v1.0.0 (2024-01-15)

  • 🎉 首次发布
  • ✨ 支持Playwright浏览器自动化
  • ✨ WebSocket实时通信
  • ✨ MySQL数据库集成
  • ✨ 完整的日志系统
  • ✨ 模块化架构设计

RPA SDK - 让自动化更简单! 🚀

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

rpa_sdk-1.1.3.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

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

rpa_sdk-1.1.3-py3-none-any.whl (73.8 kB view details)

Uploaded Python 3

File details

Details for the file rpa_sdk-1.1.3.tar.gz.

File metadata

  • Download URL: rpa_sdk-1.1.3.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for rpa_sdk-1.1.3.tar.gz
Algorithm Hash digest
SHA256 0764c14abe6f560ba56ede94c428675502192ed2206ce55dec05e38e98b3ef2d
MD5 255d540332721171765c863a3c768e2b
BLAKE2b-256 164e1476385d226079d66daa82d2d1081ad918c263abc39fd95b56a77b2bd650

See more details on using hashes here.

File details

Details for the file rpa_sdk-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: rpa_sdk-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 73.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for rpa_sdk-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 10c188d26250a2e29681e3142067d4edc11ada3a561df2e14d7e3e0bc4b77bc6
MD5 fbd57580353fce37d44e84ccf77804c4
BLAKE2b-256 6b6ba0068f23634d792b9149b8b73a8426bd529f3abe2eec46879110f1114151

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