# commission-rpa **Repository Path**: walnute/commission-rpa ## Basic Information - **Project Name**: commission-rpa - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-31 - **Last Updated**: 2025-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Selenium RPA 自动化项目 基于 Selenium 的 RPA(机器人流程自动化)项目,支持多种自动化任务处理。 ## 功能特点 - Web 自动化操作 - PDF 文档处理 - OCR 文字识别 - 消息队列集成 - 多环境配置支持 - 完善的日志系统 ## 配置使用说明 ### 1. 基本配置访问 在代码中导入并使用配置: ```python from config import config # 访问配置项 debug_mode = config.DEBUG api_timeout = config.API_TIMEOUT database_uri = config.DATABASE_URI ``` ### 2. 环境配置 项目支持多环境配置,通过 `.env` 文件和环境变量管理: 1. 基础配置(`.env`): ```env APP_ENV=local DEBUG=True SECRET_KEY=your-secret-key ``` 2. 环境特定配置(`.env.dev`, `.env.prod` 等): ```env # .env.dev DB_HOST=dev-db.example.com API_BASE_URL=https://dev-api.example.com # .env.prod DB_HOST=prod-db.example.com API_BASE_URL=https://api.example.com ``` ### 3. 配置优先级 配置加载优先级(从高到低): 1. 系统环境变量 2. `.env.{APP_ENV}` 文件 3. `.env` 文件 例如: ```bash # 通过环境变量覆盖配置 export DB_HOST=custom-host python main.py ``` ### 4. 配置验证 配置系统使用 Pydantic 进行类型验证,确保配置值的正确性: ```python # 配置类定义示例 class Settings(BaseSettings): APP_ENV: str = "local" DEBUG: bool = False DB_PORT: int = 5432 API_TIMEOUT: int = 30 ``` ### 5. 自定义配置 如需添加新的配置项: 1. 在 `config.py` 的 `Settings` 类中添加: ```python class Settings(BaseSettings): # 现有配置... # 新增配置 NEW_CONFIG: str OPTIONAL_CONFIG: Optional[str] = None ``` 2. 在相应的 `.env` 文件中添加: ```env NEW_CONFIG=value OPTIONAL_CONFIG=optional_value ``` ### 6. 配置使用示例 ```python from config import config def connect_to_database(): # 使用数据库配置 connection_string = config.DATABASE_URI # 建立数据库连接... def make_api_request(): # 使用API配置 response = requests.get( config.API_BASE_URL, timeout=config.API_TIMEOUT ) # 处理响应... def log_message(message): # 根据DEBUG配置决定日志级别 if config.DEBUG: print(f"DEBUG: {message}") else: print(f"INFO: {message}") ``` ## 环境要求 - Python 3.8 或更高版本 - Chrome 浏览器(用于 Selenium 自动化) - 系统依赖: - Windows/Linux/macOS - Poppler(PDF 处理) - Tesseract(OCR 支持) ## 安装步骤 ### 1. 克隆项目 ```bash git clone [项目地址] cd selenium-rpa ``` ### 2. 创建并激活虚拟环境 ```bash # Windows python -m venv .venv .venv\Scripts\activate # Linux/macOS python -m venv .venv source .venv/bin/activate ``` ### 3. 安装项目依赖 ```bash # 安装基础依赖 pip install -e . # 安装开发依赖(可选) pip install -e ".[dev]" ``` ### 4. 配置环境变量 1. 复制环境变量模板文件: ```bash cp .env.example .env ``` 2. 编辑 `.env` 文件,配置必要的环境变量: ```env # 应用配置 APP_ENV=local DEBUG=True SECRET_KEY=your-secret-key-here # 数据库配置 DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASS=your-password DB_NAME=your-database # API配置 API_BASE_URL=http://localhost:8000 API_TIMEOUT=30 ``` ### 5. 安装系统依赖 #### Windows 1. 安装 Poppler: - 下载 [Poppler for Windows](http://blog.alivate.com.au/poppler-windows/) - 解压到 `C:\Program Files\poppler` - 将 `C:\Program Files\poppler\bin` 添加到系统 PATH 2. 安装 Tesseract: - 下载 [Tesseract installer](https://github.com/UB-Mannheim/tesseract/wiki) - 安装时选择"Additional language data"以支持中文识别 #### Linux ```bash # Ubuntu/Debian sudo apt-get update sudo apt-get install poppler-utils tesseract-ocr # 安装中文语言包 sudo apt-get install tesseract-ocr-chi-sim ``` #### macOS ```bash brew install poppler tesseract brew install tesseract-lang ``` ## 使用说明 ### 运行项目 ```bash python main.py ``` ### 切换环境 通过设置 `APP_ENV` 环境变量来切换不同环境: ```bash # Windows set APP_ENV=dev python main.py # Linux/macOS export APP_ENV=dev python main.py ``` ### 开发工具 项目使用以下开发工具: - Black:代码格式化 - isort:导入排序 - flake8:代码检查 - pytest:单元测试 ## 项目结构 ``` selenium-rpa/ ├── config.py # 配置管理 ├── main.py # 主程序入口 ├── utils/ # 工具函数 ├── task_center/ # 任务中心 ├── selenium_rpa/ # Selenium 自动化 ├── rabbit_mq/ # 消息队列 ├── infra/ # 基础设施 └── logger/ # 日志模块 ``` ## 贡献指南 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](LICENSE)