### Create Access Token Request Example Source: https://www.yingdao.com/yddoc/language/zh-cn/%E7%AE%A1%E7%90%86%E6%96%87%E6%A1%A3/%E5%BC%80%E6%94%BEapi/api%E6%8E%A5%E5%8F%A3/%E9%89%B4%E6%9D%83.html This is an example of a GET request to create an access token. Ensure you replace 'xxx' with your actual domain and provide valid accessKeyId and accessKeySecret. ```http http://xxx/oapi/token/v2/token?accessKeyId=MerC5cKPSa7BTG1A@platform&accessKeySecret=mqTxhk4aK1v7PpDtfQU6dCMgnrR50HFc ``` -------------------------------- ### Create Access Token Request Example Source: https://www.yingdao.com/yddoc/management/3b9d810233baf0b1d10a09105f2de8db.html This is an example of a GET request to create an access token. Ensure you replace 'xxx' with your specific endpoint and provide valid accessKeyId and accessKeySecret. ```http http://xxx/oapi/token/v2/token/create?accessKeyId=MerC5cKPSa7BTG1A@platform&accessKeySecret=mqTxhk4aK1v7PpDtfQU6dCMgnrR50HFc ``` -------------------------------- ### Install Tesseract OCR Source: https://www.yingdao.com/yddoc/rpa/711756426806804480 Instructions for downloading and installing Tesseract OCR. Ensure you select the correct setup file for your system. Note that default installation does not include Chinese recognition. ```bash 下载安装包 https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w32-setup-v5.1.0.20220510.exe 运行exe,安装安装包,可选择拓展语言包,默认无中文识别 下载安装包 https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w32-setup-v5.1.0.20220510.exe 运行exe,安装安装包,可选择拓展语言包,默认无中文识别 ``` -------------------------------- ### Configuration Example Source: https://www.yingdao.com/yddoc/rpa/785063992217870336 This example shows how to configure the 'Product Information Dictionary' with specific values for 'Style' and 'Material'. ```python 产品信息字典:{'风格':'欧式','材质':'塑胶'} ``` -------------------------------- ### Get Video Duration Example Source: https://www.yingdao.com/yddoc/rpa/711902630288764928 This example demonstrates how to get the duration of a video file named 'test.mp4' and log it. Ensure the video file path is correctly set to a local file. ```Python video_path = "test.mp4" video_duration = GetVideoDuration(video_path) print(f"Video duration: {video_duration}s") ``` -------------------------------- ### Start and Enable Docker Service on CentOS Source: https://www.yingdao.com/yddoc/rpa/710400213407707136 Start the Docker service and configure it to start automatically on system boot. ```bash sudo systemctl start docker sudo systemctl start docker ``` ```bash sudo systemctl enable docker sudo systemctl enable docker ``` -------------------------------- ### Get File Name Example Source: https://www.yingdao.com/yddoc/rpa/712061041430663168 This example demonstrates how to use the 'Get File Name' command. It takes a file path as input and returns the file name, optionally including the suffix. This is useful for processing file information within RPA workflows. ```json { "command": "GetFileName", "inputs": { "FilePath": "E:\\新建文件夹\\新建文件夹\\新建.文件.txt", "NeedSuffix": "是" } } ``` -------------------------------- ### Save PSD File Example Source: https://www.yingdao.com/yddoc/rpa/711893184288337920 This example demonstrates how to get the active Photoshop object and then save it to a specified file path. Ensure the save path is valid on your system. ```en 获取激活的 PS 对象 获取当前激活的 Photoshop 文档对象保存至ps_instance ``` ```en 另存为 PSD 文件 将 Photoshop 对象 ps_instance 对应的 PSD 文件另存为 C:\Users\14422\Desktop\test.psd ``` -------------------------------- ### Install Docker Engine on Ubuntu Source: https://www.yingdao.com/yddoc/rpa/710400213407707136 Install Docker Engine, CLI, containerd, and Docker Compose plugin using apt. ```bash sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin ``` -------------------------------- ### Install Robot Application with Docker Source: https://www.yingdao.com/yddoc/rpa/710401115938041856 Run this command to download and execute the installation script for the robot application. Ensure Docker and curl are installed locally. ```bash curl https://gitee.com/shuai_luther/robot.io/raw/master2/install.sh | bash ``` ```bash curl https://gitee.com/shuai_luther/robot.io/raw/master2/install.sh | bash ``` -------------------------------- ### Verify Docker Engine Installation on Ubuntu Source: https://www.yingdao.com/yddoc/rpa/710400213407707136 Run the 'hello-world' Docker image to confirm that the Docker Engine installation was successful. ```bash sudo docker run hello-world sudo docker run hello-world ``` -------------------------------- ### Access Token Response Example Source: https://www.yingdao.com/yddoc/language/zh-cn/%E7%AE%A1%E7%90%86%E6%96%87%E6%A1%A3/%E5%BC%80%E6%94%BEapi/api%E6%8E%A5%E5%8F%A3/%E9%89%B4%E6%9D%83.html This is an example of a successful response when creating an access token. It includes the accessToken and its expiration time in seconds. ```json { "data": { "accessToken": "520da9c9-694d-4b40-9332-0c179243c88e", "expiresIn": 7199 }, "code": 200, "success": true, "requestId": "601cf6274032e2cc335c97d2" } ``` ```json { "data": { "accessToken": "520da9c9-694d-4b40-9332-0c179243c88e", "expiresIn": 7199 }, "code": 200, "success": true, "requestId": "601cf6274032e2cc335c97d2" } ``` -------------------------------- ### Create Multiple Folders Example Source: https://www.yingdao.com/yddoc/rpa/712057437021966336 This example demonstrates how to create all non-existent folders within a given path. Ensure the 'Folder Path' is replaced with a valid local file path. ```RPA 创建多级文件夹("D:\\1\\2\\3\\4") ``` -------------------------------- ### Set up Docker Repository GPG Key and Source List on Ubuntu Source: https://www.yingdao.com/yddoc/rpa/710400213407707136 Install the Docker GPG key and add the Docker repository to your apt sources list for Ubuntu. ```bash sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg ``` ```bash echo \ "deb [arch=\"`dpkg --print-architecture\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null echo \ "deb [arch=\"`dpkg --print-architecture\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ``` -------------------------------- ### 修改配置文件内容 Source: https://www.yingdao.com/yddoc/rpa/710403486730629120 使用'cat > config.py'命令并粘贴以下内容来修改'config.py'文件。根据实际需求修改'Port'、'App_Key'、'APP_SECRET'、Redis相关配置、Vika相关配置以及Ding相关配置。 ```python #服务器后台开启的安全组端口号 Port = 8111 #微应用的key和密钥,直接复制进来 App_Key = 'dingjscafpn9ta6fgesk' APP_SECRET = "YJ1RygHwhJS6VdxboH4FD-dMN_O0xC5W9m84GGulW0UvYiY0PEGy4hdGw34_Cwhq" #redis数据库的ip地址和密码,10号仓库默认收集信息,如有冲突可自行更改 Redis_ = False Redis_Host = '116.62.11.57' # IP Redis_password = '' Redis_DB = 10 # Default warehouse is 10 Redis_Port = 6379 #是否回传到维格表,打开为True #传入toekn和 sheet的id Vika_ = False Vika_token = 'uskbHxfHPTRZxThzLfpUWDD' # Vika_ 为True时 生效 Vika_dst = 'dstEorRaECyY7e5WH0' #是否记录聊天信息到钉钉在线表格,打开为True #传入userid和表格id Ding_ =False #钉钉开发 User_id = 'manager8121' Workbook_id = "v1GXn4g93gMGlDQ4" #服务器后台开启的安全组端口号 Port = 8111 #微应用的key和密钥,直接复制进来 App_Key = 'dingjscafpn9ta6fgesk' APP_SECRET = "YJ1RygHwhJS6VdxboH4FD-dMN_O0xC5W9m84GGulW0UvYiY0PEGy4hdGw34_Cwhq" #redis数据库的ip地址和密码,10号仓库默认收集信息,如有冲突可自行更改 Redis_ = False Redis_Host = '116.62.11.57' # IP Redis_password = '' Redis_DB = 10 # Default warehouse is 10 Redis_Port = 6379 #是否回传到维格表,打开为True #传入toekn和 sheet的id Vika_ = False Vika_token = 'uskbHxfHPTRZxThzLfpUWDD' # Vika_ 为True时 生效 Vika_dst = 'dstEorRaECyY7e5WH0' #是否记录聊天信息到钉钉在线表格,打开为True #传入userid和表格id Ding_ =False #钉钉开发 User_id = 'manager8121' Workbook_id = "v1GXn4g93gMGlDQ4" ``` -------------------------------- ### Get Range Content - xbot.app.databook.get_range Source: https://www.yingdao.com/yddoc/rpa/711191261314269184 Retrieves data from a specified rectangular area within the data table. Both start and end row/column are inclusive. ```python from xbot import app def main(args): list_value = app.databook.get_range(1, 'A', 3, 'F') print(list_value) ``` -------------------------------- ### Successful File Upload Response Source: https://www.yingdao.com/yddoc/management/92afa8a5290815a28a8ef52d5e55040a.html This is an example of a successful response when a file is uploaded. The 'fileKey' returned is used as an input parameter for starting applications or tasks. ```json { "data": { "fileKey": "aedbdaad-0c9c-4c05-9082-be42f0ba03a2" }, "code": 200, "success": true } ``` -------------------------------- ### Connect to Emulator via ADB Source: https://www.yingdao.com/yddoc/rpa/710940283396370432 Use this command to connect to an emulator. Ensure the ADB executable is correctly placed and the emulator is running. ```bash adb connect 127.0.0.1:62001 ``` ```bash adb connect 127.0.0.1:7555 ``` -------------------------------- ### Get Selected Range in Excel Source: https://www.yingdao.com/yddoc/rpa/711147434316005376 Opens an Excel file and retrieves the currently selected range on the active sheet. Returns a tuple indicating the start and end cells of the selection. ```python from xbot import excel def main(args): workbook = excel.open('D:\\test.xlsx', kind = 'office', visible = True) workbook.get_selected_range() ``` -------------------------------- ### Get Specific Child Element using xbot.web.Element.child_at() Source: https://www.yingdao.com/yddoc/rpa/711162930699644928 Use child_at(index) to access a child element at a specific position within the parent's children list. Indexing starts from 0. ```python from xbot import web def main(args): browser = web.create('www.baidu.com', 'chrome') web_element = browser.find('左上角的菜单栏') child_element = web_element.child_at(0) ``` -------------------------------- ### 创建配置文件 Source: https://www.yingdao.com/yddoc/rpa/710403486730629120 在服务器上创建名为'config.py'的配置文件,用于存储机器人相关的配置信息。 ```bash cd /home && touch config.py cd /home && touch config.py ``` -------------------------------- ### cURL Example for Querying RPA Account List Source: https://www.yingdao.com/yddoc/rpa/710498885910380544 This cURL command demonstrates how to make a GET request to the RPA enterprise account list API, including query parameters for filtering and the Authorization header. ```bash curl --location --request GET 'https://api.yingdao.com/oapi/rpa/user/v1/list?latestLoginTimeBegin=1680192000&latestLoginTimeEnd=1706630400&expiredTimeBegin=1678550400&expiredTimeEnd=1741708800&accountTypes=basic,senior&page=1&size=20' \ --header 'Authorization: 替换为鉴权接口返回的accessToken' curl --location --request GET 'https://api.yingdao.com/oapi/rpa/user/v1/list?latestLoginTimeBegin=1680192000&latestLoginTimeEnd=1706630400&expiredTimeBegin=1678550400&expiredTimeEnd=1741708800&accountTypes=basic,senior&page=1&size=20' \ --header 'Authorization: 替换为鉴权接口返回的accessToken' ``` -------------------------------- ### Python Unicode Escape Error Example Source: https://www.yingdao.com/yddoc/rpa/710888722111344640 This error occurs when a backslash is followed by a 'U' in a string, which Python interprets as the start of an 8-digit Unicode escape sequence. This is common when dealing with file paths or other strings containing backslashes. ```text (unicode error) 'unicodeescape' codec can't decode bytes in position X-X: truncated \UXXXXXXXX escape (unicode error) 'unicodeescape' codec can't decode bytes in position X-X: truncated \UXXXXXXXX escape ``` -------------------------------- ### 检查Docker容器运行状态 Source: https://www.yingdao.com/yddoc/rpa/710403486730629120 使用'docker ps'命令查看正在运行的Docker容器,以确认机器人容器是否已成功启动。 ```bash [root@VM-16-17-centos robot_ding]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b5dbcbc3e8a hexia666/robot_ding:1.0 "nohup python3 main.…" 15 minutes ago Up 55 seconds 0.0.0.0:8111->8111/tcp my-robot [root@VM-16-17-centos robot_ding]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b5dbcbc3e8a hexia666/robot_ding:1.0 "nohup python3 main.…" 15 minutes ago Up 55 seconds 0.0.0.0:8111->8111/tcp my-robot ``` -------------------------------- ### Get Range Content with xbot.excel.WorkSheet.get_range Source: https://www.yingdao.com/yddoc/rpa/711141551752855552 Retrieves data from a rectangular range of cells within an Excel worksheet. Specify the start and end row numbers and column names. Ensure the Excel file is opened and the worksheet is active. ```python from xbot import excel def main(args): workbook = excel.open('D:\\test.xlsx', kind = 'office', visible = True) worksheet = workbook.get_active_sheet() data = worksheet.get_range(1, 'A', 3, 'F') print(data) ``` -------------------------------- ### Connect to Emulator Port (NoxPlayer) Source: https://www.yingdao.com/yddoc/topic-basedDoc/ad425eef1331b4da07d7de584f16c273.html Use this command to connect to a NoxPlayer instance. Ensure Yingdao's ADB is used. ```bash adb connect 127.0.0.1:62001 ``` -------------------------------- ### Task and Job Callback Example Source: https://www.yingdao.com/yddoc/rpa/710489613909069824 This JSON structure represents a callback for a task or job execution. It includes details such as data type, start and end times, a list of jobs with their respective statuses and results, and overall task status. ```json { "dataType": "task", "startTime": 1, "endTime": 1642837962000, "jobList": [ { "dataType": "job", "jobUuid": "6de893bb-8224-4f60-9bff-b8597b8ed8fc", "msg": "", "robotClientUuid": "cfcc5904-2e82-4295-911c-0ce65c9099f2", "robotClientName": "ceshi1@csqy1", "startTime":"2021-02-03 11:11:11", "endTime": "2021-03-03 12:12:12", "robotName": "导出淘宝订单", "robotUuid": "xxxxx", "status": "finish", "idempotentUuid":"xxxx", "screenshotUrl":"xxxx", "result": [ { "name": "姓", "value": "王", "type": "str" }, { "name": "名", "value": "5", "type": "str" }, { "name": "上传文件", "value": "https://winrobot-pub-a-dev.oss-cn-hangzhou.aliyuncs.com/document/temp/request.txt", "type": "file" } ] } ], "msg": "运行结束", "status": "finish", "taskUuid": "ea947f83-82fb-4afb-8412-4021255fd7cd" } ``` ```json { "dataType": "task", "startTime": 1, "endTime": 1642837962000, "jobList": [ { "dataType": "job", "jobUuid": "6de893bb-8224-4f60-9bff-b8597b8ed8fc", "msg": "", "robotClientUuid": "cfcc5904-2e82-4295-911c-0ce65c9099f2", "robotClientName": "ceshi1@csqy1", "startTime":"2021-02-03 11:11:11", "endTime": "2021-03-03 12:12:12", "robotName": "导出淘宝订单", "robotUuid": "xxxxx", "status": "finish", "idempotentUuid":"xxxx", "screenshotUrl":"xxxx", "result": [ { "name": "姓", "value": "王", "type": "str" }, { "name": "名", "value": "5", "type": "str" }, { "name": "上传文件", "value": "https://winrobot-pub-a-dev.oss-cn-hangzhou.aliyuncs.com/document/temp/request.txt", "type": "file" } ] } ], "msg": "运行结束", "status": "finish", "taskUuid": "ea947f83-82fb-4afb-8412-4021255fd7cd" } ``` -------------------------------- ### Query Application Parameters by Exact Name Example Source: https://www.yingdao.com/yddoc/rpa/710473073333092352 Use this URL to query the main process parameter structure of an application by its exact name. Replace 'xxx' with the application's name. This parameter does not support fuzzy matching. ```HTTP https://api.yingdao.com/oapi/robot/v2/queryRobotParam?accurateRobotName=xxx ``` -------------------------------- ### Connect to Emulator Port (MuMu Player) Source: https://www.yingdao.com/yddoc/topic-basedDoc/ad425eef1331b4da07d7de584f16c273.html Use this command to connect to a MuMu Player instance. Ensure Yingdao's ADB is used and replace the adb_server.exe in the MuMu installation directory. ```bash adb connect 127.0.0.1:7555 ``` -------------------------------- ### Job Execution Output Example Source: https://www.yingdao.com/yddoc/rpa/710491717794512896 This JSON output represents the result of a job execution. It includes task information such as UUID, name, status, start and end times, and a list of job data, each with its own details like status, robot parameters, client information, and execution times. This structure is observed when the job runs without specific input or output parameters for the main process. ```json { "data": { "taskUuid": "4d8aae66-cec5-4043-85cc-70f4e0430d4e", "taskName": "测试-api任务", "status": "running", "statusName": "运行中", "startTime": "2022-01-22 15:10:28", "endTime": "2022-01-22 15:10:46", "jobDataList": [ { "jobUuid": "97421b0b-2f64-4adf-94b9-0bdfc73face6", "status": "created", "statusName": "已创建", "robotParams": {}, "robotClientUuid": "cfcc5904-2e82-4295-911c-0ce65c9099f2", "robotClientName": "ceshi1@csqy1", "robotUuid": "e8be5a0a-ec3a-4f3a-b4a2-b9319fe6fd0a", "robotName": "等待-10s", "startTime": "2022-01-22 15:10:28", "endTime": "2022-01-22 15:10:46", "remark": "任务创建" } ] }, "code": 200, "success": true } { "data": { "taskUuid": "4d8aae66-cec5-4043-85cc-70f4e0430d4e", "taskName": "测试-api任务", "status": "running", "statusName": "运行中", "startTime": "2022-01-22 15:10:28", "endTime": "2022-01-22 15:10:46", "jobDataList": [ { "jobUuid": "97421b0b-2f64-4adf-94b9-0bdfc73face6", "status": "created", "statusName": "已创建", "robotParams": {}, "robotClientUuid": "cfcc5904-2e82-4295-911c-0ce65c9099f2", "robotClientName": "ceshi1@csqy1", "robotUuid": "e8be5a0a-ec3a-4f3a-b4a2-b9319fe6fd0a", "robotName": "等待-10s", "startTime": "2022-01-22 15:10:28", "endTime": "2022-01-22 15:10:46", "remark": "任务创建" } ] }, "code": 200, "success": true } ``` -------------------------------- ### 启动机器人Docker容器 Source: https://www.yingdao.com/yddoc/rpa/710403486730629120 使用Docker命令拉取并启动机器人容器。此命令将容器命名为'my-robot',并将本地的'config.py'文件挂载到容器内的'/app/config.py',同时将服务器的8111端口映射到容器的8111端口。 ```bash docker run -d --name my-robot -v /home/config.py:/app/config.py -p 8111:8111 hexia666/robot_ding:2.0 docker run -d --name my-robot -v /home/config.py:/app/config.py -p 8111:8111 hexia666/robot_ding:2.0 ``` -------------------------------- ### Install Required Packages for Docker on CentOS 7 Source: https://www.yingdao.com/yddoc/rpa/710407574932291584 Installs `yum-utils` and other necessary packages for Docker installation on CentOS 7. These utilities are required for managing yum repositories and for the devicemapper storage driver. ```bash yum install -y yum-utils device-mapper-persistent-data lvm2 yum install -y yum-utils device-mapper-persistent-data lvm2 ``` -------------------------------- ### Connect to Database using ado.open() Source: https://www.yingdao.com/yddoc/rpa/711190445287260160 Use the open() method to establish a connection to a database. Requires a valid database connection string. ```python from xbot import ado def main(args): db = ado.Database() db.open('数据库连接字符串') from xbot import ado def main(args): db = ado.Database() db.open('数据库连接字符串') ``` -------------------------------- ### Install yum-utils on CentOS Source: https://www.yingdao.com/yddoc/rpa/710400213407707136 Install the 'yum-utils' package, which provides the 'yum-config-manager' utility for managing repositories. ```bash yum install -y yum-utils yum install -y yum-utils ``` -------------------------------- ### Curl File Upload Example Source: https://www.yingdao.com/yddoc/management/92afa8a5290815a28a8ef52d5e55040a.html This command shows how to upload a file using Curl. Ensure you replace '{accessToken}' with your valid token and '/path/to/file' with the actual file path. ```curl curl --location --request POST 'https://api.yingdao.com/oapi/dispatch/v2/file/upload' \ --header 'Authorization: Bearer {accessToken}' \ --form 'file=@"/path/to/file"' ```