本文档是对插件版IDE用到的所有API进行文档型描述。本处提到的API是指迈容公司基于python自动化进行的二次封装,目的是方便使用者直接调用函数,函数简单易用。
自动化范围 | 是否支持 |
---|---|
window7、8、10 | ✅ |
linux | ✅ |
自动化范围 | 包名称 | 归属 | 描述 |
---|---|---|---|
系统应用 | rpa.system | 操作系统 | 打开操作系统的命令等 |
对话框 | rpa.dialog | 操作系统 | 生成对话框界面,用于提示或者用户交互等 |
鼠标 | rpa.mouse | 鼠标 | 控制鼠标进行操作等 |
键盘 | rpa.keyboard | 键盘 | 控制键盘进行输入操作等 |
剪贴板 | rpa.clipboard | 操作系统 | 调用操作系统的剪贴板命令等 |
浏览器 | rpa.webdriver | 浏览器 | 通过webdriver控制浏览器进行自动化操作等 |
新浏览器 | rpa.page | 新浏览器 | 通过playwright控制浏览器进行自动化操作等 |
识图 | rpa.picture | 识图 | 通过识图方式进行自动化操作等 |
安卓 | rpa.android | 安卓 | 控制安卓手机进行自动化操作等 |
通用文件 | rpa.commonfile | 通用文件 | 对文件进行操作等 |
INI格式 | rpa.ini | INI格式 | 对INI格式文件进行操作等 |
CSV格式 | rpa.csvfile | CSV格式 | 对CSV格式文件进行操作等 |
PDF格式 | rpa.pdf | PDF格式 | 对PDF格式文件进行操作等 |
Word文档 | rpa.word | Word文档 | 对Word文档进行操作等 |
Excel表格 | rpa.excel | Excel表格 | 对Excel表格进行操作等 |
网络设备 | rpa.net | 网络设备 | 获取网络设备的信息等 |
HTTP | rpa.httpclient | HTTP | 进行HTTP请求操作等 |
SMTP/POP | rpa.smtp | SMTP/POP | 通过SMTP/POP对邮件进行操作等 |
FTP | rpa.ftp | FTP | 对ftp进行操作等 |
数据库 | rpa.db | 数据库 | 对数据库进行增删改查操作等 |
json | rpa.mrjson | json | 对json进行数据解析操作等 |
字符串 | rpa.mrstr | 字符串 | 对字符串类型进行数据解析操作等 |
正则表达式 | rpa.reg | 正则表达式 | 使用正则表达式进行操作等 |
数字 | rpa.mrmath | 数字 | 进行数学运算操作等 |
时间 | rpa.mrtime | 时间 | 处理日期和时间操作等 |
二维码 | rpa.mrqrcode | 二维码 | 进行识别二维码和生成二维码操作等 |
解析html | rpa.parseHtml | 解析html | 解析html并进行处理操作等 |
xxxxxxxxxx
import rpa.system
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
1000-001 | rpa.system.uname | 获取操作系统信息 | info = rpa.system.uname() |
1000-002 | rpa.system.cmdExe | 打开应用/命令 | rpa.system.cmdExe(order='cmd') |
1000-003 | rpa.system.environ | 获取环境变量 | env = rpa.system.environ() |
1000-004 | rpa.system.environGet | 读取某环境变量 | pathEnv = rpa.system.environGet(key='PATH') |
1000-005 | rpa.system.getcwd | 获取当前工作目录 | workDir = rpa.system.getcwd() |
1000-006 | rpa.system.system | 关闭指定的应用程序 | rpa.system.system(order='taskkill /F /IM 进程名') |
1000-007 | rpa.system.voice | 播放指定路径下的音频文件 | rpa.system.voice(file='D:/test/test.mp3') |
1000-008 | rpa.system.rectCapturePlus | 屏幕截图 | rpa.system.rectCapturePlus(filename=r'D:/aaaa.png') |
1000-009 | rpa.system.lockScreen | 锁屏 | rpa.system.lockScreen() |
1000-010 | rpa.system.inputMethodJudgment | 判断当前输入法 | input_method = rpa.system.inputMethodJudgment() |
1000-011 | rpa.system.setInputer | 切换输入法 | rpa.system.setInputer(lid_hex=0x0804) |
xxxxxxxxxx
import rpa.dialog
xxxxxxxxxx
import rpa.mouse
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
3000-001 | rpa.mouse.click | 鼠标点击 | rpa.mouse.click( x=0, y=0, clicks=1, interval=0, button='left', duration=0 ) |
3000-002 | rpa.mouse.moveTo | 鼠标移动 | rpa.mouse.moveTo( x=20, y=30, duration=1 ) |
3000-003 | rpa.mouse.moveRel | 鼠标相对移动 | rpa.mouse.moveRel( xOffset=0, yOffset=undefined, duration=0 ) |
3000-004 | rpa.gui.position | 获取鼠标坐标 | rpa.gui.position() |
3000-005 | rpa.mouse.dragTo | 鼠标拖动 | rpa.mouse.dragTo( x=0, y=0, button='left', duration=0 ) |
3000-006 | rpa.mouse.scroll | 鼠标滑轮滚动 | rpa.mouse.scroll(-300) |
xxxxxxxxxx
import rpa.keyboard
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
4000-001 | rpa.keyboard.typewrite | 普通输入 | rpa.keyboard.typewrite(msg=['a','b','left','left','X','Y'],interval=0.5) |
4000-002 | rpa.keyboard.hotkey | 组合快捷键 | rpa.keyboard.hotkey('ctrl', 'shift', 'r') |
4000-003 | rpa.keyboard.press | 键盘输入单个按键内容 | rpa.keyboard.press('esc') |
xxxxxxxxxx
import rpa.clipboard
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
5000-001 | rpa.clipboard.copy | 文字复制 | rpa.clipboard.copy('excel_path') |
5000-002 | rpa.clipboard.paste | 文字粘贴 | rpa.clipboard.paste() |
5000-003 | rpa.clipboard.copyImg | 图片复制 | rpa.clipboard.copyImg('c:\1.png') |
5000-004 | rpa.clipboard.pasteImg | 图片粘贴 | rpa.clipboard.pasteImg() |
xxxxxxxxxx
import rpa.webdriver
xxxxxxxxxx
import rpa.page
xxxxxxxxxx
import rpa.window
xxxxxxxxxx
import rpa.picture
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
9000-001 | rpa.picture.moveTo | 鼠标移动至图像 | rpa.picture.moveTo(pic='d:/robot/1.png') |
9000-002 | rpa.picture.findAndClick | 识别并点击图像 | rpa.picture.findAndClick(pic='d:/robot/1.png') |
9000-003 | rpa.picture.findAndDrag | 识别并拖动图像 | rpa.picture.findAndDrag(pic='d:/robot/1.png',offset_x=0,offset_y=0) |
9000-004 | rpa.picture.compare | 图像比对 | area = rpa.picture.compare(src_pic='d:/robot/src.png',dest_pic='d:/robot/dest.png') |
xxxxxxxxxx
import rpa.android
xxxxxxxxxx
import rpa.commonfile
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
11000-001 | rpa.commonfile.openFile | 获取文件对象 | fd = rpa.commonfile.openFile(path=path) |
11000-002 | rpa.commonfile.read | 读取文件 | rpa.commonfile.read(path=path) |
11000-003 | rpa.commonfile.write | 写入文件 | rpa.commonfile.write(fd=fd, text=text) |
11000-004 | rpa.commonfile.addwrite | 追加写入文件 | rpa.commonfile.addwrite(fd=fd, text=text) |
11000-005 | rpa.commonfile.close | 关闭文件 | rpa.commonfile.close(fd=fd) |
11000-006 | rpa.commonfile.getName | 获取文件名称 | rpa.commonfile.getName(path=path) |
11000-007 | rpa.commonfile.getExtension | 获取文件扩展名 | rpa.commonfile.getExtension(path=path)[1] |
11000-008 | rpa.commonfile.dirname | 获取文件路径 | rpa.commonfile.dirname(path=path) |
11000-009 | rpa.commonfile.getsize | 获取文件大小 | rpa.commonfile.getsize(path=path) |
11000-010 | rpa.commonfile.getdirsize | 获取文件夹大小 | rpa.commonfile.getdirsize(path=path) |
11000-011 | rpa.commonfile.copy | 复制文件 | rpa.commonfile.copy(path=path, targetPath=targetPath) |
11000-012 | rpa.commonfile.copyFolder | 复制文件夹 | rpa.commonfile.copyFolder(path=path, targetPath=targetPath) |
11000-013 | rpa.commonfile.move | 移动文件/文件夹 | rpa.commonfile.move(path=path, targetPath=targetPath) |
11000-014 | rpa.commonfile.rename | 重命名 | rpa.commonfile.rename(filename=filename, newfilename=newfilename) |
11000-015 | rpa.commonfile.rmdir | 删除文件 | rpa.commonfile.rmdir(path=path) |
11000-016 | rpa.commonfile.removedirs | 删除目录 | rpa.commonfile.removedirs(path=path) |
11000-017 | rpa.commonfile.mkdir | 创建目录 | rpa.commonfile.mkdir(path=path) |
11000-018 | rpa.commonfile.makedirs | 递归创建目录 | rpa.commonfile.makedirs(path=path) |
11000-019 | rpa.commonfile.exists | 判断文件/文件夹是否存在 | rpa.commonfile.exists(path=path) |
11000-020 | rpa.commonfile.isfile | 判断路径是否为文件 | rpa.commonfile.isfile(path=path) |
11000-021 | rpa.commonfile.isdir | 判断路径是否为文件夹 | rpa.commonfile.isdir(path=path) |
11000-022 | rpa.commonfile.listdir | 获取文件或文件夹列表 | rpa.commonfile.listdir(path=path) |
11000-023 | rpa.commonfile.lookup | 查找 | rpa.commonfile.lookup(path=path, name=name) |
11000-024 | rpa.commonfile.mkZip | 生成zip文件 | rpa.commonfile.mkZip(filename=filename, path=path) |
11000-025 | rpa.commonfile.decZip | 解压zip文件 | rpa.commonfile.decZip(path=path, zip_path=zip_path) |
11000-026 | rpa.commonfile.getLastedFile | 获取目录中最新日期文件 | rpa.commonfile.getLastedFile(path=path) |
11000-027 | rpa.commonfile.printFile | 文件打印 | rpa.commonfile.printFile(filename=filename) |
xxxxxxxxxx
import rpa.ini
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
12000-001 | rpa.ini.read | 读取INI文件 | fp = rpa.ini.read(filenames='D:\pythonworkspace\rb-gui-script\iniig\robot.ini') |
12000-002 | rpa.ini.getSections | 获取sections | rpa.ini.getSections() |
12000-003 | rpa.ini.getOptions | 获取options | rpa.ini.getOptions(section='section') |
12000-004 | rpa.ini.getkeys | 枚举键值 | rpa.ini.getkeys(section='section') |
12000-005 | rpa.ini.getValue | 获取值 | rpa.ini.getValue(section='number', option='wait_time') |
12000-006 | rpa.ini.removeOption | 删除Option | rpa.ini.removeOption(section='email_163', option='port') |
12000-007 | rpa.ini.removeSection | 删除Section | rpa.ini.removeSection(section='email_163') |
12000-008 | rpa.ini.addSection | 增加Section | rpa.ini.addSection(section='emali_tel') |
12000-009 | rpa.ini.setKeyValue | 设置键值 | rpa.ini.setKeyValue(section='emali_tel', option='sender', value='yoyo1@tel.com') |
12000-010 | rpa.ini.write | 追加写入文件 | rpa.ini.write(fp=fp) |
xxxxxxxxxx
import rpa.csvfile
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
13000-001 | rpa.csvfile.reader | csv文件读取器 | reader = rpa.csvfile.reader(filename = 'samples/sample.csv') |
13000-002 | rpa.csvfile.lineNum | csv行数 | rpa.csvfile.lineNum(filename = 'samples/sample.csv') |
13000-003 | rpa.csvfile.writer | csv文件写入器 | writer = rpa.csvfile.writer(filename = 'samples/sample.csv', delimiter=delimiter, lineterminator=lineterminator) |
13000-004 | rpa.csvfile.writerRow | csv文件写入一行 | rpa.csvfile.writerRow(writer=writer, row = row) |
13000-005 | rpa.csvfile.writerRows | csv文件写入多行 | rpa.csvfile.writerRows(writer=writer, rows = rows) |
13000-006 | rpa.csvfile.dictReader | csv字典读取 | dictReader = rpa.csvfile.dictReader(filename = 'samples/sample.csv', fieldnames=fieldnames) |
13000-007 | rpa.csvfile.dictWriter | csv字典写入 | rpa.csvfile.dictWriter(filename = 'samples/sample.csv', fieldnames=fieldnames, delimiter=delimiter, lineterminator=lineterminator, rows={'id':1,'name':'A'}, writeheader=False) |
xxxxxxxxxx
import rpa.pdf
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
14000-001 | rpa.pdf.getPageCount | 获取总页数 | rpa.pdf.getPageCount(file_path='D:\aaa\aa.pdf') |
14000-002 | rpa.pdf.setPageToImage | 将指定页另存为图片 | rpa.pdf.setPageToImage(file_path='D:\aaa\aa.pdf', save_path='D:\aaa', num=1) |
14000-003 | rpa.pdf.getTextOnPage | 获取指定页文本 | rpa.pdf.getTextOnPage(file_path='D:\aaa\aa.pdf', num=1) |
14000-004 | rpa.pdf.mergePDF | 合并PDF | rpa.pdf.mergePDF(filename=filename, merged_name=merged_name,passwords=None) |
14000-005 | rpa.pdf.assignSplitPdf | 拆分指定页PDF | rpa.pdf.assignSplitPdf(filename=filename, start_page=1, end_page=2, output_pdf=r'D:\aaa.pdf') |
14000-006 | rpa.pdf.splitPdf | 按页拆分PDF | rpa.pdf.splitPdf(filename=filename, output_path=r'D:\path') |
xxxxxxxxxx
import rpa.word
xxxxxxxxxx
import rpa.excel
xxxxxxxxxx
import rpa.net
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
17000-001 | rpa.net.getMacAddress | Mac地址 | mac_str = rpa.net.getMacAddress() |
17000-002 | rpa.net.getHostName | 主机名 | host_name = rpa.net.getHostName() |
17000-003 | rpa.net.getIPv4Address | IP地址(V4) | rpa.net.getIPv4Address() |
17000-004 | rpa.net.getIPv6Address | IP地址(V6) | rpa.net.getIPv6Address() |
xxxxxxxxxx
import rpa.httpclient
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
18000-001 | rpa.httpclient.doGet | Get获取数据 | response = rpa.httpclient.doGet(url=url,headers=headers,params=params) |
18000-002 | rpa.httpclient.doPost | Post提交表单 | response = rpa.httpclient.doPost(url=url,headers=headers,params=params) |
18000-003 | rpa.httpclient.upload | Post上传文件 | rpa.httpclient.upload(url=url, headers=headers, data=data, files=files) |
18000-004 | rpa.httpclient.doPut | Put请求 | response = rpa.httpclient.doPut(url=url,headers=headers,params=params) |
18000-005 | rpa.httpclient.doDelete | Delete请求 | response = rpa.httpclient.doDelete(url=url,headers=headers,params=params) |
18000-006 | rpa.httpclient.doHead | Head请求 | response = rpa.httpclient.doHead(url=url,headers=headers,params=params) |
18000-007 | rpa.httpclient.doOptions | Options请求 | response = rpa.httpclient.doOptions(url=url,headers=headers,params=params) |
xxxxxxxxxx
import rpa.smtp
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
19000-001 | rpa.smtp.send | 发送邮件 | rpa.smtp.send(smtpObj=smtpObj,from_addr='xxx@163.com', to_addrs=['429240967@qq.com'], subject='hello',context='world', filepath='c:\desktop\1.txt') |
19000-002 | rpa.smtp.connect | 连接邮箱 | smtpObj = rpa.smtp.connect(host='xxx@163.com',port=25,mail_user='admin',mail_pass='123456') |
19000-003 | rpa.smtp.disconnect | 断开邮箱连接 | rpa.smtp.disconnect(smtplib=smtpObj) |
xxxxxxxxxx
import rpa.ftp
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
20000-001 | rpa.ftp.connectFTPServer | 连接FTP服务器 | ftpconnect = rpa.ftp.connectFTPServer(ip='0.0.0.0', port=80, username='aaa', password='bbbbb') |
20000-002 | rpa.ftp.mkd | 创建远程文件夹 | rpa.ftp.mkd(ftp=ftpconnect, pathname='/aaa') |
20000-003 | rpa.ftp.nlst | 列举远程目录下的内容 | rpa.ftp.nlst(ftp=ftpconnect, path=None) |
20000-004 | rpa.ftp.exists | 判断远程文件是否存在 | rpa.ftp.exists(ftp=ftpconnect, filename='/aaa/aaa.txt') |
20000-005 | rpa.ftp.downloadFile | 下载文件 | rpa.ftp.downloadFile(ftp=ftpconnect, remotePath='/aaa/aaa.txt', localPath='D:/aaa/aaa.txt') |
20000-006 | rpa.ftp.uploadFile | 上传文件 | rpa.ftp.uploadFile(ftp=ftpconnect, remotePath='/aaa/aaa.txt', localPath='D:/aaa/aaa.txt') |
20000-007 | rpa.ftp.delete | 删除文件 | rpa.ftp.delete(ftp=ftpconnect, filename='/aaa/aaa.txt') |
20000-008 | rpa.ftp.quit | 关闭连接 | rpa.ftp.quit(ftp=ftpconnect) |
xxxxxxxxxx
import rpa.db
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
21000-001 | rpa.db.connect | 数据库连接 | db = rpa.db.connect(type='mysql', host='192.168.1.1',port=80, user='admin', password='123456', database='test') |
21000-002 | rpa.db.query | SQL查询 | data = rpa.db.query(type='mysql',db=db, sql='select * from test limit 1') |
21000-003 | rpa.db.update | SQL插入更新 | rpa.db.update(type='mysql',db=db, sql='update test set user = "123"') |
21000-004 | rpa.db.delete | SQL删除 | rpa.db.delete(type='mysql',db=db, sql='delete from test where 1 = 1') |
21000-005 | rpa.db.batch | SQL批量执行 | rpa.db.batch(type='mysql',db=db, sql=update_cmd, data =data) |
21000-006 | rpa.db.commit | 提交 | rpa.db.commit(db=db) |
21000-007 | rpa.db.rollback | 回滚 | rpa.db.rollback(db=db) |
21000-008 | rpa.db.close | 关闭连接 | rpa.db.close(db=db) |
xxxxxxxxxx
import rpa.mrjson
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
22000-001 | rpa.mrjson.loads | JSON字符串转换为对象 | rpa.mrjson.loads(json_str='{"name": "abc", "age": 1}') |
22000-002 | rpa.mrjson.dumps | 对象转换为JSON字符串 | rpa.mrjson.dumps(data={'name': 'abc', 'age': 1}) |
22000-003 | rpa.mrjson.fromFile | JSON文件转对象 | rpa.mrjson.fromFile(file='test.json') |
22000-004 | rpa.mrjson.toFile | 对象保存至Json文件 | rpa.mrjson.toFile(data={'name': 'abc', 'age': 1},file='test.json') |
xxxxxxxxxx
import rpa.mrstr
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
23000-001 | rpa.mrstr.capitalize | 首字符大写 | rpa.mrstr.capitalize('hello world') |
23000-002 | rpa.mrstr.casefold | 转为小写 | rpa.mrstr.casefold('hello world') |
23000-003 | rpa.mrstr.count | 包含次数 | rpa.mrstr.count('hello world','w') |
23000-004 | rpa.mrstr.encode | 以指定的编码格式编码字符串 | rpa.mrstr.encode('hello world','utf-8') |
23000-005 | rpa.mrstr.endswith | 结尾判断 | rpa.mrstr.endswith('hello world','d') |
23000-006 | rpa.mrstr.index | 字符串包含位置 | rpa.mrstr.index('hello world','d') |
23000-007 | rpa.mrstr.isalnum | 是否字母或数字 | rpa.mrstr.isalnum('hello world') |
23000-008 | rpa.mrstr.isalpha | 是否字母 | rpa.mrstr.isalpha('hello world') |
23000-009 | rpa.mrstr.isdecimal | 是否十进制字符 | rpa.mrstr.isdecimal('hello world') |
23000-010 | rpa.mrstr.isdigit | 是否整数 | rpa.mrstr.isdigit('hello world') |
23000-011 | rpa.mrstr.isidentifier | 是否标识符 | rpa.mrstr.isidentifier('hello world') |
23000-012 | rpa.mrstr.islower | 是否小写 | rpa.mrstr.islower('hello world') |
23000-013 | rpa.mrstr.isnumeric | 是否数字 | rpa.mrstr.isnumeric('hello world') |
23000-014 | rpa.mrstr.isprintable | 是否可打印 | rpa.mrstr.isprintable('hello world') |
23000-015 | rpa.mrstr.isspace | 是否空格 | rpa.mrstr.isspace('hello world') |
23000-016 | rpa.mrstr.isupper | 是否全大写 | rpa.mrstr.isupper('hello world') |
23000-017 | rpa.mrstr.lower | 转换小写 | rpa.mrstr.lower('hello world') |
23000-018 | rpa.mrstr.replace | 替换指定字符串 | rpa.mrstr.replace('hello world','h','d') |
23000-019 | rpa.mrstr.split | 字符串拆分 | rpa.mrstr.split('hello world','h') |
23000-020 | rpa.mrstr.startswith | 开头判断 | rpa.mrstr.startswith('hello world','h') |
23000-021 | rpa.mrstr.swapcase | 大小写切换 | rpa.mrstr.swapcase('hello world') |
23000-022 | rpa.mrstr.upper | 转大写 | rpa.mrstr.upper('hello world') |
xxxxxxxxxx
import rpa.reg
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
24000-001 | rpa.reg.find | 正则表达式查找子串 | rpa.reg.find(pattern='www', string='www.baidu.com', flags=0) |
24000-002 | rpa.reg.findall | 正则表达式查找全部子串 | rpa.reg.findall(pattern='d+', string='runoob 123 google 456', flags=0) |
24000-003 | rpa.reg.sub | 正则表达式替换 | rpa.reg.sub(pattern='D', repl='', string='2004-959-559 # 这是一个电话号码', count=0, flags=0) |
xxxxxxxxxx
import rpa.mrmath
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
25000-001 | rpa.mrmath.constant | 数学常量 | rpa.mrmath.constant(const='pi') |
25000-002 | rpa.mrmath.base | 基本运算 | rpa.mrmath.base(flag='add', x1=0, x2=0) |
25000-003 | rpa.mrmath.pow | 进制转化 | rpa.mrmath.pow(flag='bin', x=0) |
25000-004 | rpa.mrmath.common | 通用函数 | rpa.mrmath.common(0,1,flag='ceil') |
25000-005 | rpa.mrmath.expLog | 幂/对数函数 | rpa.mrmath.expLog(flag='exp', x=0, y=0) |
25000-006 | rpa.mrmath.trigonometric | 三角函数 | rpa.mrmath.trigonometric(flag='acos', x=0, y=0) |
25000-007 | rpa.mrmath.degree | 角度转换 | rpa.mrmath.degree(flag='degrees', x=0) |
25000-008 | rpa.mrmath.hyperbolic | 双曲函数 | rpa.mrmath.hyperbolic(flag='acosh', x=0) |
25000-009 | rpa.mrmath.getRounding | 特殊函数 | rpa.mrmath.getRounding(flag='erf', x=0) |
25000-010 | rpa.mrmath.randomfunc | 随机函数 | rpa.mrmath.randomfunc(flag='randint', x=0, y=0) |
25000-011 | rpa.mrmath.convert | 数值转化 | rpa.mrmath.convert(flag='float', x=0) |
xxxxxxxxxx
import rpa.mrtime
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
26000-001 | rpa.mrtime.getStamp | 获取时间戳 | rpa.mrtime.getStamp() |
26000-002 | rpa.mrtime.getTimes | 获取时间 | rpa.mrtime.getTimes() |
26000-003 | rpa.mrtime.the_other_day | 获取T+n的时间 | rpa.mrtime.the_other_day(1) |
26000-004 | rpa.mrtime.getDate | 获取日期 | rpa.mrtime.getDate() |
26000-005 | rpa.mrtime.fromatTime | 格式化时间 | rpa.mrtime.fromatTime(date=date, timeformat=timeformat, newtimeformat=newtimeformat) |
26000-006 | rpa.mrtime.getYear | 获取年份 | rpa.mrtime.getYear() |
26000-007 | rpa.mrtime.getMonth | 获取月份 | rpa.mrtime.getMonth() |
26000-008 | rpa.mrtime.getDay | 获取天 | rpa.mrtime.getDay() |
26000-009 | rpa.mrtime.getHour | 获取小时 | rpa.mrtime.getHour() |
26000-010 | rpa.mrtime.getMinute | 获取分钟 | rpa.mrtime.getMinute() |
26000-011 | rpa.mrtime.getSeconds | 获取秒数 | rpa.mrtime.getSeconds() |
26000-012 | rpa.mrtime.getWeek | 获取本周第几天 | rpa.mrtime.getWeek() |
26000-013 | rpa.mrtime.difference | 计算时间差 | rpa.mrtime.difference(time1=time1, time2=time2, timeformat=timeformat) |
26000-014 | rpa.mrtime.differ_day | 计算天数 | rpa.mrtime.differ_day(time1=time1, time2=time2, timeformat=timeformat) |
26000-015 | rpa.mrtime.strToTime | 字符串转换为时间 | rpa.mrtime.strToTime(timestr=timestr, timeformat=timeformat) |
xxxxxxxxxx
import rpa.mrqrcode
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
27000-001 | rpa.mrqrcode.identifyqrcode | 图像二维码识别 | rpa.mrqrcode.identifyqrcode(file='test.jpg') |
27000-002 | rpa.mrqrcode.createqrcode | 生成二维码 | rpa.mrqrcode.createqrcode(data='1234', file='test.jpg') |
xxxxxxxxxx
import rpa.parseHtml
内部编号 | 函数名称 | 函数作用 | 完整函数 |
---|---|---|---|
28000-001 | rpa.parseHtml.getHtmlObj | 获取html对象 | htmlobj = rpa.parseHtml.getHtmlObj(html=html) |
28000-002 | rpa.parseHtml.getTables | 提取表格数据 | htmlTable = rpa.parseHtml.getTables(html=html) |
28000-003 | rpa.parseHtml.getImages | 提取图片数据 | htmlImg = rpa.parseHtml.getImages(html=html) |
28000-004 | rpa.parseHtml.downloadImg | 下载图片数据 | rpa.parseHtml.downloadImg(html=html, picpath=r'C:ImageDownload', picFormat='jpg') |
......
获取操作系统当前用户
xxxxxxxxxx
info =rpa.system.uname()
参数说明:
无参数
返回值说明:
"info":系统用户名,字符串类型
打开应用或命令窗口
xxxxxxxxxx
rpa.system.cmdExe(order='cmd')
参数说明:
"order":应用名或命令窗口,字符串类型
返回值说明:
无返回值
获取环境变量信息,并返回环境变量值
xxxxxxxxxx
env = rpa.system.environ()
参数说明:
无参数
返回值说明:
"os._Environ",对象类型
返回值示例:
environ({'ALLUSERSPROFILE': 'C:\\ProgramData', 'APPDATA': 'C:\\Users\\78445\\AppData\\Roaming', 'CHOCOLATEYINSTALL': 'C:\\ProgramData\\chocolatey', 'CHOCOLATEYLASTPATHUPDATE': '132734059696094131', 'CLASSPATH': '.;D:\\jdk1.8\\lib;D:\\jdk1.8\\lib\\tools.jar', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files', 'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'DESKTOP-6KHE4TA', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'DRIVERDATA': 'C:\\Windows\\System32\\Drivers\\DriverData', 'FPS_BROWSER_APP_PROFILE_STRING': 'Internet Explorer', 'FPS_BROWSER_USER_PROFILE_STRING': 'Default', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Users\\78445', 'IDEA_INITIAL_DIRECTORY': 'C:\\Users\\78445\\Desktop', 'JAVA_HOME': 'D:\\jdk1.8', 'LOCALAPPDATA': 'C:\\Users\\78445\\AppData\\Local', 'LOGONSERVER': '\\\\DESKTOP-6KHE4TA', 'NUMBER_OF_PROCESSORS': '16', 'ONEDRIVE': 'C:\\Users\\78445\\OneDrive', 'OS': 'Windows_NT', 'PATH': 'D:\\Xshell\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;D:\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;D:\\Git\\cmd;D:\\jdk1.8\\bin;D:\\jdk1.8\\jre\\bin;D:\\Python;D:\\Python\\Scripts;D:\\poppler-0.68.0\\bin;D:\\apache-maven-3.8.2\\bin;C:\\Program Files\\dotnet\\;C:\\Users\\78445\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\78445\\AppData\\Roaming\\npm;D:\\PyCharm 2021.2\\bin;;D:\\Microsoft VS Code\\bin;C:\\Users\\78445\\.deno\\bin;C:\\Users\\78445\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\78445\\.dotnet\\tools', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD', 'PROCESSOR_LEVEL': '23', 'PROCESSOR_REVISION': '6001', 'PROGRAMDATA': 'C:\\ProgramData', 'PROGRAMFILES': 'C:\\Program Files', 'PROGRAMFILES(X86)': 'C:\\Program Files (x86)', 'PROGRAMW6432': 'C:\\Program Files', 'PSMODULEPATH': 'C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules', 'PUBLIC': 'C:\\Users\\Public', 'PYCHARM': 'D:\\PyCharm 2021.2\\bin;', 'PYCHARM_DISPLAY_PORT': '63343', 'PYCHARM_HOSTED': '1', 'PYTHONIOENCODING': 'UTF-8', 'PYTHONPATH': 'D:\\pythonworkspace\\rb-gui-script;D:\\PyCharm 2021.2\\plugins\\python\\helpers\\pycharm_matplotlib_backend;D:\\PyCharm 2021.2\\plugins\\python\\helpers\\pycharm_display', 'PYTHONUNBUFFERED': '1', 'SESSIONNAME': 'Console', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\\Users\\78445\\AppData\\Local\\Temp', 'TESSDATA_PREFIX': 'C:\\Program Files (x86)\\Tesseract-OCR', 'TMP': 'C:\\Users\\78445\\AppData\\Local\\Temp', 'USERDOMAIN': 'DESKTOP-6KHE4TA', 'USERDOMAIN_ROAMINGPROFILE': 'DESKTOP-6KHE4TA', 'USERNAME': '78445', 'USERPROFILE': 'C:\\Users\\78445', 'WINDIR': 'C:\\WINDOWS'})
读取某环境变量
xxxxxxxxxx
pathEnv = rpa.system.environGet(key='PATH')
参数说明:
"key":系统指定路径,字符串类型
返回值说明:
"pathEnv",系统环境变量的值,字符串类型
获取当前工作目录并返回值
xxxxxxxxxx
workDir = rpa.system.getcwd()
参数说明:
无参数
返回值说明:
"workDir":字符串类型
关闭指定的应用程序
xxxxxxxxxx
rpa.system.system(order='taskkill /F /IM 进程名')
参数说明:
"order":指定目录下的进程名
返回值说明:
无返回值
播放指定路径下的音频文件
xxxxxxxxxx
rpa.system.voice(file='D:/test/test.mp3')
参数说明:
"file":指定路径下的音频文件
返回值说明:
无返回值
屏幕截图
xxxxxxxxxx
flag = rpa.system.rectCapturePlus(filename=r'D:/aaaa.png')
参数说明:
"filename":截屏图片保存全路径,字符串类型
返回值说明:
"flag":操作成功标志(成功为True,失败为False),boolean类型
锁屏
xxxxxxxxxx
rpa.system.lockScreen()
参数说明:
无参数
返回值说明:
无参数
判断当前输入法
xxxxxxxxxx
input_method = rpa.system.inputMethodJudgment()
参数说明:
无参数
返回值说明:
"input_method":输入法描述(当前的输入法是英文输入法/当前的输入法是中文输入法),字符串
切换输入法
xxxxxxxxxx
rpa.system.setInputer(lid_hex=0x0804)
参数说明:
"lid_hex",输入法类型0x0409为英文输入法的lid_hex的 中文一般为0x0804,字符串类型
返回值说明:
无返回值
创建一个提示框
xxxxxxxxxx
rpa.dialog.msgbox(msg='提示', title='标题', ok_button='确认', image=None, root=None)
参数说明:
"msg":提示信息 ,可不传,缺省值为"提示"
"title":标题信息 ,可不传,缺省值为"标题"
"ok_button":按钮 ,可不传,缺省值为"确认"
"image":图片信息 ,
"root":图片信息 ,
返回值说明:
无返回值
创建一个单行输入框.
xxxxxxxxxx
value = rpa.dialog.enterbox(msg='内容', title='标题', default='缺省值', strip=True, image=None, root=None)
参数说明:
"msg":提示信息 ,可不传,缺省值为"提示"
"title":标题信息 ,可不传,缺省值为"标题"
"ok_button":按钮 ,可不传,缺省值为"确认"
"image":图片信息 ,
"root":图片信息 ,
返回值说明:
"result",输入框中填写的内容,字符串类型
创建一个单行密码输入框
xxxxxxxxxx
value = rpa.dialog.passwordbox(msg='Enter your password.', title=' ', default='', image=None, root=None)
参数说明:
"msg":提示信息
"title":标题信息
"default":输入信息
"image":图片信息
返回值说明:
"value":密码框中填入的密码值,字符串类型
创建一个多行输入框
xxxxxxxxxx
input_value =rpa.dialog.multenterbox(msg='Fill in values for the fields.', title=' ', fields=fields)
参数说明:
"msg":提示信息
"title":标题信息
"fileds":输入框名称,必传,元组类型
返回值说明:
"input_value",多行输入框中的录入值,列表类型
创建一个登录框
xxxxxxxxxx
input_value = rpa.dialog.multpasswordbox(msg='Fill in values for the fields.', title=' ', fields=fields)
参数说明:
"msg":提示信息
"title":标题信息
"fileds":登录框名称
返回值说明:
"input_value": 登录框中每个输入框中的录入值,列表类型
返回用户选择的目录名(带完整路径),如果用户选择“Cancel”则返回None
xxxxxxxxxx
path = rpa.dialog.diropenbox(msg=None, title=None, default=None)
参数说明:
"msg":提示信息
"title":标题信息
"default":用于设置默认的打开目录(请确保目录已存在)
返回值说明:
"path":选中的目录,用户选择“Cancel”则返回None,字符串类型
从指定目录打开文件
xxxxxxxxxx
path = rpa.dialog.fileopenbox(msg=None, title=None, default='*',filetypes=None)
参数说明:
"msg":提示信息,非必传
"title":标题信息,非必传
"default":指定默认路径,通常包含一个或多个通配符.非必传
"filetypes":文件描述类型,非必传
返回值说明:
"path":选中的文件全路径,用户选择“Cancel”则返回None,字符串类型
保存文件到指定目录
xxxxxxxxxx
path = rpa.dialog.filesavebox(msg=None, title=None, default='',filetypes=None)
参数说明:
"msg":提示信息,非必传
"title":标题信息,非必传
"default":指定默认路径,通常包含一个或多个通配符.非必传
"filetypes":文件描述类型,非必传
返回值说明:
"path":保存的文件全路径,用户选择“Cancel”则返回None,字符串类型
创建一个列表选择框
xxxxxxxxxx
result = rpa.dialog.choicebox(msg='Pick something.', title=' ', choices=choices)
参数说明:
"msg":提示信息
"title":标题信息
"choicse":选项值,必传,列表类型,示例:["Vanilla", "Chocolate", "Strawberry", "Rocky Road"]
返回值说明:
"result":选中的选择框的值,字符串类型
执行鼠标点击操作.
xxxxxxxxxx
rpa.mouse.click( x=0, y=0, clicks=1, interval=0, button='left', duration=0 )
参数说明:
"x","y":点击位置的横纵坐标轴,非必传,默认 x=0, y=0
"clicks":为点击次数
"interval":鼠标点击时间
"button":选择鼠标键位
"left":鼠标左键
"right":鼠标右键
"middle":鼠标中键
"duration":动作完成时间
返回值说明:
无返回值
鼠标移动到指定位置.
xxxxxxxxxx
rpa.mouse.moveTo( x=20, y=30, duration=1 )
参数说明:
"x","y":移动位置的横纵坐标轴
"duration":动作完成时间,非必传,默认1
返回值说明:
无返回值
鼠标从上一位置移动到指定位置,相对移动.
xxxxxxxxxx
rpa.mouse.moveRel( xOffset=0, yOffset=0, duration=0 )
参数说明:
"xOffest":目标位置横坐标偏移量,非必传,默认0
"yOffest":目标位置纵坐标偏移量,非必传,默认0
"duration":动作完成时间, 非必传,默认0
返回值说明:
无返回值
获取鼠标当前所在位置,返回一个(x,y)坐标
xxxxxxxxxx
point = rpa.mouse.position()
参数说明:
无参数
返回值说明:
"point":鼠标的x,y坐标,对象类型,示例:Point(x=1282, y=686)
鼠标从当前位置拖动到指定位置
xxxxxxxxxx
rpa.mouse.dragTo( x=0, y=0, button='left', duration=0 )
参数说明:
"x"、"y"为拖动到的指定位置的坐标
"duration"为拖动时间
"button":选择鼠标键位
"left":鼠标左键
"right":鼠标右键
"middle":鼠标中键
返回值说明:
无返回值
鼠标滑轮移动的距离
xxxxxxxxxx
rpa.mouse.scroll(-300)
参数说明:
"num":滑动距离,正数为向上滑动,负数为向下滑动
返回值说明:
无返回值
键盘输入数字、字母...
xxxxxxxxxx
rpa.keyboard.typewrite(msg=['a','b','left','left','X','Y'],interval=0.5)
参数说明:
"msg":键入字符串信息,必传,列表类型
"interval":两次键入时间间隔
返回值说明:
无返回值
键盘输入组合键,其中输入的参数为需要键入的组合键内容
xxxxxxxxxx
rpa.keyboard.hotkey('ctrl', 'shift', 'r')
参数说明:
多个字符串,以逗号分隔,必传
返回值说明:
无返回值
键盘输入单个按键内容,参数为要输入的按键
xxxxxxxxxx
rpa.keyboard.press(key='esc')
参数说明:
"key":按键值,必传,字符串类型
返回值说明:
无返回值
复制内容到剪切板
xxxxxxxxxx
rpa.clipboard.copy(context='esc')
参数说明:
"context":复制到剪切板的字符串,必传,字符串类型
返回值说明:
无返回值
从剪切板粘贴
xxxxxxxxxx
rpa.clipboard.paste()
参数说明:
无参数
返回值说明:
无返回值
复制图片
xxxxxxxxxx
rpa.clipboard.copyImg(path=None)
参数说明:
"path":复制的图片全路径,必传,字符串类型
返回值说明:
无返回值
粘贴图片
xxxxxxxxxx
rpa.clipboard.pasteImg()
参数说明:
无参数
返回值说明:
无返回值
创建并启动一个浏览器
xxxxxxxxxx
driver = rpa.webdriver.create()
参数说明:
无参数
返回值说明:
"driver":浏览器驱动,对象类型
绑定已启动地浏览器
xxxxxxxxxx
driver = rpa.webdriver.bind(ip='127.0.0.1:9222')
参数说明:
"ip":已打开浏览器地址和连接端口,字符串类型
返回值说明:
"driver":浏览器驱动,对象类型
打开浏览器网页
xxxxxxxxxx
rpa.webdriver.get(driver=driver, url='http://www.baidu.com')
参数说明:
"driver":浏览器驱动对象,必传
"url":要访问的地址,必传
返回值说明:
无返回值
退出或关闭当前浏览器
xxxxxxxxxx
rpa.webdriver.quitOrClose(driver=driver, msg=0)
参数说明:
"driver":浏览器驱动对象,必传
"msg":浏览器操作,(0 退出浏览器 1 关闭浏览器),非必传,默认0
返回值说明:
无返回值
设置获取元素时需要等待的时间
xxxxxxxxxx
rpa.webdriver.explicitWait(driver=driver, timeout=10, key='id', xpath='kw')
参数说明:
"driver":浏览器驱动对象,必传
"timeout":等待时间,必传
"key":获取元素方式,必传
"xpath":获取元素路径,必传
返回值说明:
无返回值
获取当前浏览器页面的网页源码
xxxxxxxxxx
html = rpa.webdriver.parseHtml(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
"html": 网页源代码,字符串类型
执行 js 脚本
xxxxxxxxxx
flag = rpa.webdriver.executeJs(driver=driver, value='window.open()')
参数说明:
"driver":浏览器驱动对象,必传
"value":js脚本代码,非必传
返回值说明:
"flag":执行js结果标志(True成功,False失败),boolean类型
设置当前浏览器页面的 cookie 中的参数值
xxxxxxxxxx
rpa.webdriver.setCookie(driver=driver, value='cookie')
参数说明:
"driver":浏览器驱动对象,必传
"value":cookie的参数名,必传
返回值说明:
无返回值
获取当前 cookie 并返回 cookie 值
xxxxxxxxxx
cookie = rpa.webdriver.getCookie(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
"cookie":浏览器cookie内容,字符串类型
刷新当前浏览器页面
xxxxxxxxxx
rpa.webdriver.refresh(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
无返回值
定位元素,并返回会获取到的元素值
xxxxxxxxxx
element = rpa.webdriver.findElement(msg='id', driver=driver, path='kw')
参数说明:
"msg":元素定位标签,必传
"driver":浏览器驱动对象,必传
"path":目标元素Xpath路径,必传
返回值说明:
"element":元素对象,对象类型
定位多个元素,并返回会获取到的元素值
xxxxxxxxxx
elements = rpa.webdriver.findElements(msg='id', driver=driver, path='kw')
参数说明:
"msg":元素定位标签,必传
"driver":浏览器驱动对象,必传
"path":目标元素Xpath路径,必传
返回值说明:
"elements":返回元素列表,列表类型
元素触发处理
xxxxxxxxxx
result = rpa.webdriver.operElement(key='click', element=element, value=None)
参数说明:
"key":元素操作,必传,字符串(click-点击,send_keys-传入内容, clear-清空内容,get_attribute-获取元素属性值,getText-获取文本内容)
"element":目标元素对象名称,必传
"value":元素定位条件,除入参为click与clear外必传,字符串类型
返回值说明:
入参key值为click、send_keys、clear时无返回值
入参key值为get_attribute 、getText 返回值为字符串类型的值
切换iframe并返回切换到的iframe
xxxxxxxxxx
rpa.webdriver.toFrame(driver=driver, value=0)
参数说明:
"driver":浏览器驱动对象,必传
"value":Frame窗口对象名称,必传
返回值说明:
无返回值
切换到上一个iframe,并返回iframe值
xxxxxxxxxx
rpa.webdriver.parentFrame(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
无返回值
表单提交
xxxxxxxxxx
rpa.webdriver.submit(element=element)
参数说明:
"element":提交的表单元素,必传
返回值说明:
无返回值
滚动至元素处
xxxxxxxxxx
rpa.webdriver.scrollIntoView(driver=driver,element=element)
参数说明:
"driver":浏览器驱动对象,必传
"element":浏览器元素,必传
返回值说明:
无返回值
网页向左右或上下滚动
xxxxxxxxxx
rpa.webdriver.scroll(driver=driver, i=0, a=0)
参数说明:
"driver":浏览器驱动对象,必传
"i":左右滚动,非必传,默认值0,整数类型 向右滑动为正数
"a":上下滚动,非必传,默认值0,整数类型 向下滑动为正数
返回值说明:
无返回值
元素拖动
xxxxxxxxxx
rpa.webdriver.elementDrag(driver=driver,element1=element1,element2=element2)
参数说明:
"driver":浏览器驱动对象,必传
"element1":拖动的浏览器元素,必传
"element2":拖至的浏览器元素,必传
返回值说明:
无返回值
元素偏移拖动
xxxxxxxxxx
rpa.webdriver.elementDragByOffset(driver=driver,element=element,x=100,y=100)
参数说明:
"driver":浏览器驱动对象,必传
"element":拖动的浏览器元素,必传
"x":水平偏移量,向右为正,整数类型,非必传,默认值0
"x":垂直偏移量,向下为正,整数类型,非必传,默认值0
返回值说明:
无返回值
浏览器窗口最大或最小化
xxxxxxxxxx
rpa.webdriver.maxOrMin(driver=driver, msg=0)
参数说明:
"driver":浏览器驱动对象名称,必传
"msg" 最大化最小化操作标志,为0时最大化,"msg"为1时最小化,非必输,默认值0
返回值说明:
无返回值
获取当前浏览器窗口并返回
xxxxxxxxxx
window_handle = rpa.webdriver.getWindowHandle(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
"window_handle" : 窗口句柄,对象类型
获取所有窗口
xxxxxxxxxx
window_handles = rpa.webdriver.getAllWindowHandle(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
"window_handles" : 窗口句柄列表,列表类型
切换到下一个窗口
xxxxxxxxxx
rpa.webdriver.changeWindow(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
无返回值
切换到指定窗口
xxxxxxxxxx
rpa.webdriver.changeAssignWindow(driver=driver,window_handle=window_handle)
参数说明:
"driver":浏览器驱动对象,必传
"window_handle":指定窗口句柄,必传
返回值说明:
无返回值
切换到最后一个窗口
xxxxxxxxxx
rpa.webdriver.changeEndWindow(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
无返回值
关闭其他窗口
xxxxxxxxxx
rpa.webdriver.closeOtherWindow(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
无返回值
浏览器页面前进或后退
xxxxxxxxxx
rpa.webdriver.forwardOrBack(driver=driver, msg=0)
参数说明:
"driver":浏览器驱动对象,必传
"msg":页面前进后退标志,为"0"时前进,位"1"时后退,必传
返回值说明:
无返回值
截取当前浏览器图片,并返回图片存放路径
xxxxxxxxxx
rpa.webdriver.screenShot(driver=driver, fileName='./aaa.png')
参数说明:
"driver":浏览器驱动对象,必传
"fileName":图片存放路径,必传,字符串类型
返回值说明:
无返回值
浏览器元素截图
xxxxxxxxxx
rpa.webdriver.elementScreenshot(element=element, fileName='./aaa.png')
参数说明:
"driver":浏览器驱动对象,必传
"fileName":图片存放路径,必传,字符串类型
返回值说明:
无返回值
获取弹窗
xxxxxxxxxx
alert = rpa.webdriver.getAlert(driver=driver)
参数说明:
"driver":浏览器驱动对象,必传
返回值说明:
"alert":弹窗对象,对象类型
获取弹窗内容
xxxxxxxxxx
text = rpa.webdriver.textAlert(alert=alert)
参数说明:
"alert":弹窗对象,必传,对象类型
返回值说明:
"text":弹窗中的文本,字符串类型
点击弹窗确认
xxxxxxxxxx
rpa.webdriver.acceptAlert(alert=alert)
参数说明:
"alert":弹窗对象,必传,对象类型
返回值说明:
无返回值
输入数据至弹窗
xxxxxxxxxx
rpa.webdriver.sendkeysAlert(alert=alert,text=text)
参数说明:
"alert":弹窗对象,必传,对象类型
"text":弹窗中要输入的文本,必传,字符串类型
返回值说明:
无返回值
弹窗取消
xxxxxxxxxx
rpa.webdriver.dismissAlert(alert=alert)
参数说明:
"alert":弹窗对象,必传,对象类型
返回值说明:
无返回值
创建一个浏览器页面并返回上下文在后续的启动浏览器中对上下文操作
xxxxxxxxxx
with sync_playwright() as playwright:
context = rpa.page.create(playwright=playwright)
参数说明:
无参数
返回值说明:
"context":上下文对象
选择启动浏览器类型,并创建page对象
xxxxxxxxxx
page = rpa.page.newPage(context=context)
参数说明:
"context":上下文对象,必传
返回值说明:
"page":页面对象
在创建的浏览器页面里打开一个新网页
xxxxxxxxxx
rpa.page.goPage(page=page, url='https://www.baidu.com')
参数说明:
"page":页面对象,必传
"url":新网页地址,必传,字符串类型
返回值说明:
无返回值
在打开的页面中根据Xpath定位元素
xxxxxxxxxx
element = rpa.page.locator(page=page, xpath="//div[@class='class1']")
参数说明:
"page":页面对象,必传
"xpath":元素路径,必传,字符串类型
返回值说明:
"element":定位的元素对象
等待元素加载
xxxxxxxxxx
rpa.page.waitUtil(page=page, xpath="//div[@text='name']", condition='attached', timeout=2000)
参数说明:
"page":页面对象,必传
"xpath":元素路径,必传,字符串类型
"condition":等待元素状态:
"attached":等待元素出现在DOM树中
"detached":等待元素消失在DOM树中
"hidden":等待元素从DOM中分离出来,或者有一个空的边界框或visibility:hidden
"visible":有非空的边界框和非visibility:hidden
"timeout":等待时间(毫秒),必传,float类型
返回值说明:
无返回值
对定位的元素执行操作,参数"operation"为操作属性
xxxxxxxxxx
rpa.page.handle(loactor=loactor, operation='click')
参数说明:
"loactor":元素对象,必传
"operation":操作类型,必传:
"click":单击;
"check":复选框勾选;
"dbclick":双击;
"focus":聚焦;
返回值说明:
无返回值
定位网页iframe
xxxxxxxxxx
rpa.page.swtichFrame(page=page, xpath="//div[@text='name']")
参数说明:
"page":页面对象,必传
"xpath":定位的iframe路径,必传
返回值说明:
无返回值
执行js脚本
xxxxxxxxxx
rpa.page.executeJs(page=page, js='window.open()')
参数说明:
"page":页面对象,必传
"js":js脚本,必传
返回值说明:
无返回值
通过键盘在网页输入指定字符串
xxxxxxxxxx
rpa.page.keyboardType(page=page, context='value')
参数说明:
"page":页面对象,必传
"context":输入值,必传,字符串类型
返回值说明:
无返回值
键入键盘按键
xxxxxxxxxx
rpa.page.keyboardPress(page=page, keymap='Shift')
参数说明:
"page":页面对象,必传
"keymap":键入的键盘按键,必传,字符串类型
返回值说明:
无返回值
通过鼠标点击指定坐标位置
xxxxxxxxxx
rpa.page.mouseClick(page=page, x=10, y=10)
参数说明:
"page":页面对象,必传
"x":x轴坐标,必传
"y":y轴坐标,必传
返回值说明:
无返回值
通过鼠标双击指定坐标位置
xxxxxxxxxx
rpa.page.mouseDbclick(page=page, x=10, y=10)
参数说明:
"page":页面对象,必传
"x":x轴坐标,必传
"y":y轴坐标,必传
返回值说明:
无返回值
将鼠标移动到指定位置
xxxxxxxxxx
rpa.page.mouseMove(page=page, x=10, y=10)
参数说明:
"page":页面对象,必传
"x":x轴坐标,必传
"y":y轴坐标,必传
返回值说明:
无返回值
鼠标滚动到指定坐标位置
xxxxxxxxxx
rpa.page.mouseWheel(page=page, x=10, y=10)
参数说明:
"page":页面对象,必传
"x":x轴坐标,必传
"y":y轴坐标,必传
返回值说明:
无返回值
浏览器页面截图
xxxxxxxxxx
rpa.page.screenShot(page=page, path='c:\desktop\1.png')
参数说明:
"page":页面对象,必传
"path":图片保存路径,必传,字符串类型
返回值说明:
无返回值
对话框操作
xxxxxxxxxx
rpa.page.dialog(dialog=dialog, operation='accept')
参数说明:
"dialog":对话框对象,必传
"operation":对话框操作("accept":确认;"dismiss":关闭)
返回值说明:
无返回值
刷新页面
xxxxxxxxxx
rpa.page.reload(page=page)
参数说明:
"page":页面对象,必传
返回值说明:
无返回值
获取并返回网页源码
xxxxxxxxxx
pageSource = rpa.page.getPageSource()
参数说明:
无参数
返回值说明:
"pageSource":页面源码,字符串类型
关闭当前网页
xxxxxxxxxx
rpa.page.close(page=page)
参数说明:
"page":创建的页面
返回值说明:
无返回值
退出当前打开的浏览器
xxxxxxxxxx
rpa.page.quit(page=page)
参数说明:
"page":页面对象,必传
返回值说明:
无返回值
指定操作窗口
xxxxxxxxxx
operWindow = rpa.window.get(searchDepth = 1, ClassName = 'CalcFrame', Desc='Calculator Window')
参数说明:
"searchDepth":层级
"ClassName":class名称
"Desc":中文描述
返回值说明:
"operWindow":操作窗口对象
设置活动窗口
xxxxxxxxxx
rpa.window.setActive(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
无返回值
窗口隐藏/显示
xxxxxxxxxx
rpa.window.visiblity(operWindow = operWindow, value = 'hide')
参数说明:
"operWindow":窗口对象
"value":窗口操作(显示或隐藏)
返回值说明:
无返回值
窗口是否存在
xxxxxxxxxx
result = rpa.window.isExist(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
"result":判断结果
获取窗口大小
xxxxxxxxxx
x,y = rpa.window.getSize(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
"x":窗口x坐标
"y":窗口y坐标
窗口最大化/最小化
xxxxxxxxxx
rpa.window.minMax(operWindow = operWindow, value = 'min')
参数说明:
"operWindow":窗口对象
"value":窗口操作(最大化或最小化)
返回值说明:
无返回值
窗口调整
xxxxxxxxxx
rpa.window.reSize(operWindow = operWindow, x = 0, y = 0)
参数说明:
"operWindow":窗口对象
"x":长
"y":宽
返回值说明:
无返回值
窗口置顶
xxxxxxxxxx
rpa.window.top(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
无返回值
获取进程PID
xxxxxxxxxx
varId = rpa.window.pid(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
"varId":获取到的进程PID
关闭窗口
xxxxxxxxxx
rpa.window.close(operWindow = operWindow)
参数说明:
"operWindow":窗口对象
返回值说明:
无返回值
查找指定元素
xxxxxxxxxx
operControl = rpa.window.findControl(operWindow = operWindow, name = 'wechat')
参数说明:
"operWindow":窗口对象
"name":元素名称
返回值说明:
"operControl":查找到的元素
获取子元素
xxxxxxxxxx
childList = rpa.window.getChildren(operControl = operControl)
参数说明:
"operControl":元素对象
返回值说明:
"childList":查找到的元素
获取父元素
xxxxxxxxxx
parentId = rpa.window.getParent(operControl = operControl)
参数说明:
"operControl":元素对象
返回值说明:
"parentId":查找到的元素
元素指定操作
xxxxxxxxxx
rpa.window.oper(operControl = operControl, operate = 'click', x = 100, y = 200, text = '')
参数说明:
"operControl":元素对象
"operate":元素操作
"x":x轴偏移量
"y":y轴偏移量
"text":文本
返回值说明:
无返回值
判断元素是否存在
xxxxxxxxxx
result = rpa.window.operControlIsExist(operControl = operControl)
参数说明:
"operControl":元素对象
返回值说明:
"result":判断结果
获取元素特征
xxxxxxxxxx
value = rpa.window.getAttribute(operControl = operControl, propertyId = 0)
参数说明:
"operControl":元素对象
"propertyId":属性ID
返回值说明:
"value":获取的结果
鼠标移动至图像
xxxxxxxxxx
rpa.picture.moveTo(pic='d:/robot/1.png')
参数说明:
"pic":图片路径,必传,字符串类型
返回值说明:
无返回值
识别并点击图像
xxxxxxxxxx
rpa.picture.findAndClick(pic='d:/robot/1.png')
参数说明:
"pic":图片路径,必传,字符串类型
返回值说明:
无返回值
识别并拖动图像
xxxxxxxxxx
rpa.picture.findAndDrag(pic='d:/robot/1.png', offset_x=0, offset_y=0)
参数说明:
"pic":图片路径,必传,字符串类型
"offset_x":横坐标相对距离,必传
"offset_y":纵坐标相对距离,必传
返回值说明:
无返回值
图像对比
xxxxxxxxxx
area = rpa.picture.compare(src_pic='d:/robot/src.png', dest_pic='d:/robot/dest.png')
参数说明:
"src_pic":原图片路径,必传,字符串类型
"dest_pic":要比对的图片路径,必传,字符串类型
返回值说明:
"area":相似度
查看连接设备
xxxxxxxxxx
device_list = rpa.android.list()
参数说明:
无参数
返回值说明:
"device_list":连接的设备列表
查看手机设备连接并在终端输出一个手机序列号
xxxxxxxxxx
d = rpa.android.connect(ip='0.0.0.0')
参数说明:
"ip":ip,必传,字符串
返回值说明:
"d":设备对象
获取手机信息
xxxxxxxxxx
info = rpa.android.deviceInfo(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"info":设备信息
获取手机详细信息
xxxxxxxxxx
detailInfo = rpa.android.deviceDetailInfo(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"detailInfo":设备详细信息
获取手机序列号
xxxxxxxxxx
serial = rpa.android.deviceSerial(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"detailInfo":设备序列号
关闭手机连接
xxxxxxxxxx
rpa.android.closeConnect(ip='0.0.0.0:80')
参数说明:
"ip":ip,必传,字符串
返回值说明:
无返回值
启动APP
xxxxxxxxxx
rpa.android.startApp(device=d,apk='com.meizu.mzbbs')
参数说明:
"device":设备对象,必传
"apk":手机应用名,必传
返回值说明:
无返回值
关闭APP
xxxxxxxxxx
rpa.android.closeApp(device=d,apk='com.meizu.mzbbs')
参数说明:
"device":设备对象,必传
"apk":手机应用名,必传
返回值说明:
无返回值
重启手机
xxxxxxxxxx
rpa.android.restart(ip='0.0.0.0:80')
参数说明:
"ip":ip,必传,字符串
返回值说明:
无返回值
关闭手机
xxxxxxxxxx
rpa.android.close()
参数说明:
无参数
返回值说明:
无返回值
获取元素对象
xxxxxxxxxx
ele = rpa.android.getElement()
参数说明:
无参数
返回值说明:
"ele":手机元素
点击元素
xxxxxxxxxx
rpa.android.touch(device=d,path='//*[@resource-id="com.miui.home:id/workspace"]
参数说明:
"device":设备对象,必传
"path":元素xpath,必传
返回值说明:
无返回值
输入信息至元素
xxxxxxxxxx
rpa.android.input(device=d,path='//*[@resource-id="com.miui.home:id/workspace"]',text='hello')
参数说明:
"device":设备对象,必传
"path":元素xpath,必传
"text":输入内容,必传
返回值说明:
无返回值
清除元素内容
xxxxxxxxxx
rpa.android.clear(device=d,path='//*[@resource-id="com.miui.home:id/workspace"]')
参数说明:
"device":设备对象,必传
"path":元素xpath,必传
返回值说明:
无返回值
获取元素文本
xxxxxxxxxx
text = rpa.android.text(device=d,path='//*[@resource-id="com.miui.home:id/workspace"]
参数说明:
"device":设备对象,必传
"path":元素xpath,必传
返回值说明:
"text":文本内容
触摸滑动
xxxxxxxxxx
rpa.android.touchSlide(device=d, direction='right', scale=0.8)
参数说明:
"device":设备对象,必传
"direction":滑动方向,必传("left":左;"up":上;"right":右;"bottom":下)
"scale":刻度,必传
返回值说明:
无返回值
键盘按键
xxxxxxxxxx
rpa.android.clickKey(device=d,press_key='home')
参数说明:
"device":设备对象,必传
"press_key":手机按键名称,必传
返回值说明:
无返回值
屏幕截图
xxxxxxxxxx
rpa.android.capture(device=d,name='home.jpg')
参数说明:
"device":设备对象,必传
"name":保存路径,必传
返回值说明:
无返回值
点击屏幕
xxxxxxxxxx
rpa.android.clickScreen(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
无返回值
获取剪切板内容
xxxxxxxxxx
content = rpa.android.getClipboardContent(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"content":剪切板内容
设置剪切板内容
xxxxxxxxxx
rpa.android.setClipboardContent(device=d,text='str')
参数说明:
"device":设备对象,必传
"text":文本内容,必传
返回值说明:
无返回值
获取屏幕方向
xxxxxxxxxx
direction = rpa.android.getScreenDirection(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"direction":屏幕方向
获取UI树
xxxxxxxxxx
uiTreeObj = rpa.android.getUITree(device=d)
参数说明:
"device":设备对象,必传
返回值说明:
"uiTreeObj": UI树图对象
推送文件至手机
xxxxxxxxxx
rpa.android.pushFile(device=d, file_name='foo.txt', path='/sdcard/')
参数说明:
"device":设备对象,必传
"file_name":文件名,必传
"path":文件所在目录路径,必传
返回值说明:
无返回值
获取文件从手机
xxxxxxxxxx
rpa.android.getFile(device=d,path='/sdcard/tmp.txt', file_name='tmp.txt')
参数说明:
"device":设备对象,必传
"file_name":文件名,必传
"path":文件所在目录路径,必
返回值说明:
无返回值
打开普通文件
xxxxxxxxxx
file = rpa.commonfile.openFile(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"file":文件对象
读取文件
xxxxxxxxxx
info = rpa.commonfile.read(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"info":文件内容
写入字符串到文件对象中
xxxxxxxxxx
rpa.commonfile.write(fd=fd, text=text)
参数说明:
"fd":文件对象,必传
"text":写入的文本,必传
返回值说明:
无返回值
不改变原文件文本,追加文本写入文件
xxxxxxxxxx
flag = rpa.commonfile.addwrite(fd=fd, text=text)
参数说明:
"fd":文件对象,必传
"text":追加写入的文本,必传
返回值说明:
"flag":写入成功标志,Ture成功,False失败
关闭文件
xxxxxxxxxx
info = rpa.commonfile.close(fd=fd)
参数说明:
"fd":文件对象
返回值说明:
无返回值
获取文件名称
xxxxxxxxxx
info = rpa.commonfile.getName(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"info":文件名称
获取文件扩展名
xxxxxxxxxx
info = rpa.commonfile.getExtension(path=path)[1]
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"info":文件扩展名
获取文件路径
xxxxxxxxxx
info = rpa.commonfile.dirname(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"info":文件路径
获取文件大小
xxxxxxxxxx
size = rpa.commonfile.getsize(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"size":文件大小
获取文件夹大小
xxxxxxxxxx
size = rpa.commonfile.getdirsize(path=path)
参数说明:
"path":文件路径,必传,字符串类型
返回值说明:
"size":文件夹大小
复制文件并粘贴到另一目录
xxxxxxxxxx
rpa.commonfile.copy(path=path, targetPath=targetPath)
参数说明:
"path":文件路径,必传,字符串类型
"targetPath":粘贴文件路径,必传,字符串类型
返回值说明:
无返回值
复制文件夹并粘贴到另一目录
xxxxxxxxxx
rpa.commonfile.copyFolder(path=path, targetPath=targetPath)
参数说明:
"path":文件夹路径,必传,字符串类型
"targetPath":粘贴文件夹路径,必传,字符串类型
返回值说明:
无返回值
移动文件或文件夹到指定目录
xxxxxxxxxx
rpa.commonfile.move(path=path, targetPath=targetPath)
参数说明:
"path":要移动的文件或文件夹,必传,字符串类型
"targetPath":指定目录,必传,字符串类型
返回值说明:
无返回值
重命名文件或文件夹
xxxxxxxxxx
rpa.commonfile.rename(filename=filename, newfilename=newfilename)
参数说明:
"filename":旧文件名,必传,字符串类型
"newfilename":新文件名,必传,字符串类型
返回值说明:
无返回值
删除指定文件
xxxxxxxxxx
rpa.commonfile.rmdir(path=path)
参数说明:
"path":指定文件路径,必传,字符串类型
返回值说明:
无返回值
删除指定目录
xxxxxxxxxx
rpa.commonfile.removedirs(path=path)
参数说明:
"path":指定目录路径,必传,字符串类型
返回值说明:
无返回值
创建目录
xxxxxxxxxx
rpa.commonfile.mkdir(path=path)
参数说明:
"path":创建的目录名,必传,字符串类型
返回值说明:
无返回值
递归创建目录
xxxxxxxxxx
rpa.commonfile.makedirs(path=path)
参数说明:
"path":递归创建的目录名,必传,字符串类型
返回值说明:
无返回值
判断文件/文件夹是否存在
xxxxxxxxxx
flag = rpa.commonfile.exists(path=path)
参数说明:
"path":要判断的文件夹或文件夹名,必传,字符串类型
返回值说明:
"flag":存在标志,True存在False不存在
判断路径是否为文件
xxxxxxxxxx
flag = rpa.commonfile.isfile(path=path)
参数说明:
"path":要判断的路径,必传,字符串类型
返回值说明:
"flag":是否为文件标志,True时False否
判断路径是否为文件夹
xxxxxxxxxx
flag = rpa.commonfile.isdir(path=path)
参数说明:
"path":要判断的路径,必传,字符串类型
返回值说明:
"flag":是否为文件夹标志,True时False否
获取文件或文件夹列表
xxxxxxxxxx
list = rpa.commonfile.listdir(path=path)
参数说明:
"path":要获取信息的文件或文件夹路径路径,必传,字符串类型
返回值说明:
"list":文件或文件夹列表
查找指定路径下的文件
xxxxxxxxxx
info = rpa.commonfile.lookup(path=path, name=name)
参数说明:
"path":指定路径,必传,字符串类型
"name":文件名,必传,字符串类型
返回值说明:
"info":有文件返回文件全路径,无文件返回None
将指定文件压缩成ZIP文件
xxxxxxxxxx
info = rpa.commonfile.mkZip(filename=filename, path=path)
参数说明:
"filename":指定文件夹,必传,字符串类型
"path":指定目录,必传,字符串类型
返回值说明:
"info":压缩后的文件名
将ZIP文件解压到指定目录
xxxxxxxxxx
rpa.commonfile.decZip(path=path, zip_path=zip_path)
参数说明:
"path":指定目录,必传,字符串类型
"zip_path":指定ZIP文件路径,必传,字符串类型
返回值说明:
无返回值
获取目录中最新日期文件
xxxxxxxxxx
info = rpa.commonfile.getLastedFile(path=path)
参数说明:
"path":指定目录,必传,字符串类型
返回值说明:
"info":最新日期文件名
文件打印
xxxxxxxxxx
rpa.commonfile.printFile(filename=filename)
参数说明:
"filename":文件路径,必传,字符串类型
返回值说明:
无返回值
读取INI文件
xxxxxxxxxx
info = rpa.ini.read(filenames='D:\pythonworkspace\rb-gui-script\iniig\robot.ini')
参数说明:
"filenames":ini文件路径,必传,字符串类型
返回值说明:
"info":文件对象
获取INI文件所有Sections
xxxxxxxxxx
info = rpa.ini.getSections()
参数说明:
无参数
返回值说明:
"info":ini文件中所有的sections
获取指定section下的options
xxxxxxxxxx
info = rpa.ini.getOptions(section='section')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
返回值说明:
"info":指定section下的options
枚举指定section下所有的option与value
xxxxxxxxxx
info = rpa.ini.getkeys(section='section')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
返回值说明:
"info":指定section下所有的option与value
获取指定section与option的value值
xxxxxxxxxx
info = rpa.ini.getValue(section='number', option='wait_time')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
"option":ini文件中指定的option值,必传,字符串类型
返回值说明:
"info":指定section与option的value值
删除指定option
xxxxxxxxxx
rpa.ini.removeOption(section='email_163', option='port')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
"option":ini文件中指定的option值,必传,字符串类型
返回值说明:
无返回值
删除指定section
xxxxxxxxxx
rpa.ini.removeSection(section='email_163')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
返回值说明:
无返回值
增加section
xxxxxxxxxx
rpa.ini.addSection(section='emali_tel')
参数说明:
"section":需要增加的section值,必传,字符串类型
返回值说明:
无返回值
重新设置INI文件中的Section与Option的value
xxxxxxxxxx
rpa.ini.setKeyValue(section='emali_tel', option='sender', value='yoyo1@tel.com')
参数说明:
"section":ini文件中指定的section值,必传,字符串类型
"option":ini文件中指定的option值,必传,字符串类型
"value":ini文件中的新value值,必传,字符串类型
返回值说明:
无返回值
追加写入文件,对ini文件做出修改后,需追加写入文件才可生效。
xxxxxxxxxx
rpa.ini.write(fp=fp)
参数说明:
"fp":文件路径,必传,字符串类型
返回值说明:
无返回值
读取csv文件
xxxxxxxxxx
csv = rpa.csvfile.reader(filename = 'samples/sample.csv')
for row in reader:print(row)
参数说明:
"filename":CSV文件路径,必传,字符串类型
返回值说明:
"csv":csv对象
读取csv行数
xxxxxxxxxx
row = rpa.csvfile.lineNum(filename = 'samples/sample.csv')
参数说明:
"filename":CSV文件路径,必传,字符串类型
返回值说明:
"row":csv文件行数
csv文件写入器
xxxxxxxxxx
# 分隔符,取值 '\t', ',' 等
delimiter = '\t'
# 获取指定csv的分隔符
# delimiter = getDelimiter(reader)
# 行分隔符,取值 '\n' 等
lineterminator = '\n'
# 获取指定csv的行分隔符
# lineterminator = getLineterminator(reader)
rpa.csvfile.writer(filename = 'samples/sample.csv', delimiter=delimiter, lineterminator=lineterminator)
参数说明:
"filename":CSV文件路径,必传,字符串类型
"delimiter":分隔符,必传,字符串类型
"lineterminator":行终止符,必传,字符串类型
返回值说明:
无返回值
csv写入一行
xxxxxxxxxx
row = ['spam', 'eggs', 'bacon', 'ham']
rpa.csvfile.writerRow(writer=writer, row = row)
参数说明:
"writer":csv对象,必传
"row":添加数据,必输,列表类型
返回值说明:
无返回值
csv写入多行
xxxxxxxxxx
rows = [['spam', 'eggs', 'bacon', 'ham'],['spam', 'eggs', 'bacon', 'ham']]
rpa.csvfile.writerRows(writer=writer, rows = rows)
参数说明:
"writer":csv对象,必传
"row":添加数据,必传,列表类型
返回值说明:
无返回值
csv字典读取
xxxxxxxxxx
dictReader = rpa.csvfile.dictReader(filename = 'samples/sample.csv', fieldnames=fieldnames)
参数说明:
"filename":csv路径,必传,字符串类型
"fieldnames":字段名
返回值说明:
无返回值
csv字典写入
xxxxxxxxxx
fieldnames=['id','name']
rpa.csvfile.dictWriter(filename = 'samples/sample.csv', fieldnames=fieldnames, delimiter=delimiter, lineterminator=lineterminator, rows={'id':1,'name':'A'}, writeheader=False)
参数说明:
"filename":csv路径,必传,字符串类型
"fieldnames":行标题,必传,字符串类型
"delimiter":分隔符,必传,字符串类型
"lineterminator":行终止符,必传,字符串类型
"rows":字典类型行数据,必传,字典类型
"writeheader":是否插入行标题,必传,boolean类型
返回值说明:
无返回值
获取PDF总页数
xxxxxxxxxx
count = rpa.pdf.getPageCount(file_path='D:\aaa\aa.pdf')
参数说明:
"file_path":PDF文件路径,必传,字符串类型
返回值说明:
"count":总页数
将PDF文件中指定页另存为图片
xxxxxxxxxx
rpa.pdf.setPageToImage(file_path='D:\aaa\aa.pdf', save_path='D:\aaa', num=1)
参数说明:
"file_path":PDF文件路径,必传,字符串类型
"save_path":保存图片路径,必传,字符串类型
"num":指定页,必传,数字类型
返回值说明:
无返回值
获取指定页文本
xxxxxxxxxx
info = rpa.pdf.getTextOnPage(file_path='D:\aaa\aa.pdf', num=1)
参数说明:
"file_path":PDF文件路径,必传,字符串类型
"num":指定页,必传,数字类型
返回值说明:
"info":指定页文本
合并PDF
xxxxxxxxxx
rpa.pdf.mergePDF(filename=filename, merged_name=merged_name,passwords=None)
参数说明:
"filename":文件列表,必传,字符串类型
"merged_name":合并后的文件全路径带文件名和后缀,必传,字符串类型
"passwords":对应的密码列表,非必传
返回值说明:
无返回值
拆分指定页PDF
xxxxxxxxxx
rpa.pdf.assignSplitPdf(filename=filename, start_page=1, end_page=2, output_pdf=r'D:\aaa.pdf')
参数说明:
"filename":待分割的pdf文件名,必传,字符串类型
"start_page":执行分割的开始页数,必传,数字类型
"end_page":执行分割的结束位页数,必传,数字类型
"output_pdf":保存切割后的文件名,必传,字符串类型
返回值说明:
无返回值
按页拆分PDF
xxxxxxxxxx
rpa.pdf.splitPdf(filename=filename, output_path=r'D:\path')
参数说明:
"filename":pdf文件路径,必传,字符串类型
"output_path":存放路径,必传,字符串类型
返回值说明:
无返回值
创建word对象
xxxxxxxxxx
word = rpa.word.create()
参数说明:
无参数
返回值说明:
"word":word对象
获取所有段落对象
xxxxxxxxxx
paragraphs = rpa.word.getParagraphs(document=document)
参数说明:
"document":文档对象,必传
返回值说明:
"paragraphs":段落对象
获取段落文本
xxxxxxxxxx
paragraphText = rpa.word.getParagraphText(paragraph=paragraph)
参数说明:
"paragraphs":段落对象,必传
返回值说明:
"paragraphText":段落文本
添加标题
xxxxxxxxxx
rpa.word.addHead(document=document, title='hello world', level=1)
参数说明:
"document":word对象,必传
"title":标题信息,必传,字符串类型
"level":标题级别,必传,数字类型
返回值说明:
无参数
添加内容
xxxxxxxxxx
rpa.word.addParagraph(document=document, context='start paragraph')
参数说明:
"document":word对象,必传
"context":添加文本内容信息,必传,字符串类型
返回值说明:
无参数
添加图片
xxxxxxxxxx
rpa.word.addPic(document=document, context='1.png')
参数说明:
"document":word对象,必传
"context":添加图片全路径,必传,字符串类型
返回值说明:
无返回
添加表格
xxxxxxxxxx
rpa.word.addTable(document=document, rows=2, cols=2)
参数说明:
"document":word对象,必传
"rows":添加行数,必传,数字类型
"cols":添加列数,必传,数字类型
返回值说明:
无返回
添加表格内容
xxxxxxxxxx
rpa.word.addTableContext(table=table, row=2, column=2,context='1111')
参数说明:
"table":doc表格对象,必传
"rows":添加行数,必传,数字类型
"column":添加列数,必传,数字类型
"context":添加内容,必传,字符串类型
返回值说明:
无返回
指定表格追加多行内容
xxxxxxxxxx
rpa.word.addTableContexts(table=table, records=records)
参数说明:
"table":doc表格对象,必传
"records":添加内容,必传,列表类型 [[1,2,3],[4,5,6]]
返回值说明:
无返回
文档保存
xxxxxxxxxx
rpa.word.save(document=document, path=path)
参数说明:
"document":word对象,必传
"path":文档保存路径,必传,字符串类型
返回值说明:
无返回
更新样式
xxxxxxxxxx
rpa.word.updateFormat(paragraph='hello system', bold=True, italic=True, underline=True, color='red', fontname='微软雅黑')
参数说明:
"paragraph":段落内容对象,必传
"bold":是否加粗,非必传,默认False
"True":是
"False":否
"italic":是否设置斜体,非必传,默认False
"True":是
"False":否
"underline":是否加下划线,非必传,默认False
"True":是
"False":否
"color":设置颜色,非必传,默认None
"fontname":设置字体,非必传,默认None
返回值说明:
无返回
关键字替换
xxxxxxxxxx
rpa.word.replaceChar(document=document, oldStr='a', newStr='b')
参数说明:
"document":word对象,必传
"oldStr":原字符串,必传,字符串类型
"newStr":新字符串,必传,字符串类型
返回值说明:
无返回
Word转PDF
xxxxxxxxxx
rpa.word.wordTurnPdf(wordFile=r'D:a.docx', pdfFile=r'D:a.pdf')
参数说明:
"wordFile":word文档路径,必传
"pdfFile":pdf文件路径,必传,字符串类型
返回值说明:
无返回
xls转xlsx
xxxxxxxxxx
rpa.excel.xls2xlsx(filename=r'd:\aaaa.xls')
参数说明:
"filename":excel文件路径及名称,必传,字符串类型
返回值说明:
无返回
获取Excle对象
xxxxxxxxxx
workbook = rpa.excel.get_excel_object(filename=r'xx.xlsx' )
参数说明:
"filename":excel文件路径及名称,必传,字符串类型
返回值说明:
无返回
创建Excle对象
xxxxxxxxxx
workbook = rpa.excel.create_excel_object()
参数说明:
无参数
返回值说明:
"workbook":工作簿对象
保存Excle工作簿
xxxxxxxxxx
rpa.excel.save(workbook=workbook, filename=None)
参数说明:
"workbook":excel文件对象,必传
"filename":excel文件路径及名称,必传,字符串类型
返回值说明:
无返回
新建sheet表
xxxxxxxxxx
rpa.excel.create_sheet(workbook=workbook, newSheetName='新的sheet名')
参数说明:
"workbook":excel文件对象,必传
"newSheetName":新的sheet名,必传,字符串类型
返回值说明:
无返回
获取所有sheet名
xxxxxxxxxx
sheet = rpa.excel.get_sheetnames(workbook=workbook)
参数说明:
"workbook":excel文件对象,必传
返回值说明:
"sheet":工作表对象
获取sheet表对象
xxxxxxxxxx
sheet = rpa.excel.get_sheet(workbook=workbook, sheetName='sheet1')
参数说明:
"workbook":excel文件对象,必传
"sheetName":sheet名,必传,字符串类型
返回值说明:
"sheet":工作表对象
删除sheet表
xxxxxxxxxx
rpa.excel.remove_sheet(workbook=workbook, sheet=sheet)
参数说明:
"workbook":excel文件对象,必传
"sheet":工作表对象 ,必传,字符串类型
返回值说明:
无返回
复制sheet表
xxxxxxxxxx
rpa.excel.copy_sheet(workbook=workbook, sheet=sheet)
参数说明:
"workbook":excel文件对象,必传
"sheet":sheet对象名称,,必传,字符串类型
返回值说明:
"list":表格内容
修改sheet表名称
xxxxxxxxxx
rpa.excel.title_sheet(sheet=sheet, newSheetName='新的sheet名')
参数说明:
"sheet":sheet对象,必传
"newSheetName":新的sheet名,必传,字符串类型
返回值说明:
无返回
读取单元格
xxxxxxxxxx
cell = rpa.excel.get_cell(sheet=sheet, rowOrColumn='A1')
参数说明:
"sheet":sheet对象,必传
"rowOrColumn":单元格编号,必传,字符串类型
返回值说明:
"cell":单元格对象
读取单元格数据
xxxxxxxxxx
cell_value = rpa.excel.get_cell_value(sheet=sheet, rowOrColumn='A1')
参数说明:
"sheet":sheet对象,必传
"rowOrColumn":单元格编号,必传,字符串类型
返回值说明:
"cell_value":单元格文本内容
读取单元格行数据
xxxxxxxxxx
row_data = rpa.excel.get_rows_value(sheet=sheet, row=1)
参数说明:
"sheet":sheet对象,必传
"row":行号,必传,数字类型
返回值说明:
"row_data":行数据 ,列表类型
读取单元格列数据
xxxxxxxxxx
column_data = rpa.excel.get_columns_value(sheet=sheet, column='A')
参数说明:
"sheet":sheet对象,必传
"column":列号,必传,字符串类型
返回值说明:
"column_data":列数据,列表类型
读取所有单元格数据
xxxxxxxxxx
cells_value = rpa.excel.get_all_value(sheet=sheet)
参数说明:
"sheet":sheet对象,必传
返回值说明:
"cells_value":单元格数据,列表类型
读取指定区域单元格数据
xxxxxxxxxx
cells_value = rpa.excel.get_area_value(sheet=sheet, start_cell='A1', end_cell='B2')
参数说明:
"sheet":sheet对象,必传
"start_cell":开始单元格编号,必传,字符串类型
"end_cell":结束单元格编号,必传,字符串类型
返回值说明:
"cells_value":单元格数据,列表类型
设置单元格数据
xxxxxxxxxx
rpa.excel.set_cell(sheet=sheet, cellName='A1', data='aaaa')
参数说明:
"sheet":sheet对象,必传
"rowOrColumn":单元格编号,必传,字符串类型
"data":数据,必传,字符串类型
返回值说明:
无返回值
插入行数据
xxxxxxxxxx
# 单行数据
rowData=['唐僧','男','180cm']
# 多行数据
# rowData=[['唐僧','男','180cm'], ['孙悟空','男','181cm']]
rpa.excel.append(sheet=sheet, rowData=rowData)
参数说明:
"sheet":sheet对象,必传
"rowData":行数据,必传,列表类型
返回值说明:
无返回值
插入空列
xxxxxxxxxx
rpa.excel.insert_cols(sheet=sheet, idx=1, amount=2)
参数说明:
"sheet":sheet对象,必传
"idx":列位置,必传,数字类型
"amount":数量,必传,数字类型
返回值说明:
无返回值
插入空行
xxxxxxxxxx
rpa.excel.insert_rows(sheet=sheet, idx=1, amount=2)
参数说明:
"sheet":sheet对象,必传
"idx":行位置,必传,数字类型
"amount":数量,必传,数字类型
返回值说明:
无返回值
删除行
xxxxxxxxxx
rpa.excel.delete_rows(sheet=sheet, idx=1)
参数说明:
"sheet":sheet对象,必传
"idx":行位置,必传,数字类型
返回值说明:
无返回值
删除列
xxxxxxxxxx
rpa.excel.delete_cols(sheet=sheet, idx=1)
参数说明:
"sheet":sheet对象,必传
"idx":列位置,必传,数字类型
返回值说明:
无返回值
移动单元格
xxxxxxxxxx
rpa.excel.move_range(sheet=sheet, cell_range='C1:D4', rows=2, cols=-1)
参数说明:
"sheet":sheet对象,必传
"cell_range":单元格范围,必传,字符串类型
"rows":移动行数,必传,数字类型
"cols":移动列数,必传,数字类型
返回值说明:
无返回值
冻结窗口
xxxxxxxxxx
rpa.excel.freeze_panes(sheet=sheet, cellName='C4')
参数说明:
"sheet":sheet对象,必传
"cellName":单元格编号,必传,字符串类型
返回值说明:
无返回值
添加筛选器
xxxxxxxxxx
rpa.excel.set_filter(sheet=sheet, cellName='A1')
参数说明:
"sheet":sheet对象,必传
"cellName":单元格编号,必传,字符串类型
返回值说明:
无返回值
修改字体样式
xxxxxxxxxx
rpa.excel.set_font(cell=cell, name='微软雅黑',size=20,bold=True,italic=True,color='FF0000')
参数说明:
"cell":cell对象,必传
"name":字体名称,非必传,默认None
"size":字体大小,非必传,默认0
"bold":是否加粗,非必传,默认False
"True":是
"False":否
"italic":是否斜体,非必传,默认False
"True":是
"False":否
"color":颜色,非必传,默认None
返回值说明:
无返回值
获取字体样式
xxxxxxxxxx
font = rpa.excel.get_font(cell=cell)
参数说明:
"cell":cell对象,必传
返回值说明:
"font":字体样式
设置对齐样式
xxxxxxxxxx
rpa.excel.set_alignment(cell=cell,horizontal='center',vertical='center',text_rotation=45,wrap_text=True)
参数说明:
"cell":cell对象,必传
"horizontal":水平对齐方式,非必传,默认None
"vertical":垂直对齐方式,非必传,默认None
"text_rotation":旋转角度,非必传,默认0
"wrap_text":是否自动行,非必传,默认False
返回值说明:
无返回值
边框样式
xxxxxxxxxx
side = rpa.excel.cell_side(style='thin',color='FF0000')
参数说明:
"style":样式,必传,字符串类型
"color":颜色,必传,字符串类型
返回值说明:
"side":side对象
设置边框样式
xxxxxxxxxx
rpa.excel.set_side_style(cell=cell,left=side1,right=side1,top=side2,bottom=side2)
参数说明:
"cell":cell对象,必传
"left":左边框,非必传,默认None
"right":右边框,非必传,默认None
"top":上边框,非必传,默认None
"bottom":下边框,非必传,默认None
返回值说明:
无返回值
设置填充样式
xxxxxxxxxx
rpa.excel.set_pattern_fill(cell=cell,fill_type='solid',fgColor='99ccff')
参数说明:
"cell":cell对象,必传
"fill_type":填充样式,非必传,默认None
"fgColor":背景色,非必传,默认None
返回值说明:
无返回值
设置填充渐变样式
xxxxxxxxxx
rpa.excel.set_gradient_fill(cell=cell, stop=('FFFFFF','99ccff','000000'))
参数说明:
"cell":cell对象,必传
"stop":背景色,元组类型,非必传,默认()
返回值说明:
无返回值
设置行高
xxxxxxxxxx
rpa.excel.set_row_dimensions(sheet=sheet, row=1, dimensions=50)
参数说明:
"sheet":sheet对象,必传
"row":行位置,非必传,数字类型,默认1
"dimensions":行高,非必传,数字类型,默认50
返回值说明:
无返回值
设置列宽
xxxxxxxxxx
rpa.excel.set_column_dimensions(sheet=sheet, column=1, dimensions=50)
参数说明:
"sheet":sheet对象,必传
"column":列编号,非必传,数字类型,默认1
"dimensions":列宽,非必传,数字类型,默认50
返回值说明:
无返回值
合并单元格
xxxxxxxxxx
rpa.excel.merge_cells(sheet=sheet, range_string='C1:D2', start_row=None, start_column=None, end_row=None, end_column=None)
参数说明:
"sheet":sheet对象,必传
"range_string":被合并的单元格,非必传,默认None,字符串类型
"start_row":开始行,非必传,默认None,数字类型
"start_column":开始列,非必传,默认None,数字类型
"end_row":结束行,非必传,默认None,数字类型
"end_column":结束列,非必传,默认None,数字类型
返回值说明:
无返回值
取消合并单元格
xxxxxxxxxx
rpa.excel.unmerge_cells(sheet=sheet, range_string='C1:D2', start_row=None, start_column=None, end_row=None, end_column=None)
参数说明:
"sheet":sheet对象,必传
"range_string":被合并的单元格,非必传,默认None,字符串类型
"start_row":开始行,非必传,默认None,数字类型
"start_column":开始列,非必传,默认None,数字类型
"end_row":结束行,非必传,默认None,数字类型
"end_column":结束列,非必传,默认None,数字类型
返回值说明:
无返回值
获取主机的MAC地址
xxxxxxxxxx
address = rpa.net.getMacAddress()
参数说明:
无参数
返回值说明:
"address":主机的MAC地址
获取主机名
xxxxxxxxxx
host = rpa.net.getHostName()
参数说明:
无参数
返回值说明:
"host":主机名
获取主机IPv4地址
xxxxxxxxxx
address_ipv4 = rpa.net.getIPv4Address()
参数说明:
无参数
返回值说明:
"address_ipv4":主机IPv4地址
获取主机IPv6地址
xxxxxxxxxx
address_ipv6 = rpa.net.getIPv6Address()
参数说明:
无参数
返回值说明:
"address_ipv6":主机IPv6地址
通过GET请求获取数据
xxxxxxxxxx
response = rpa.httpclient.doGet(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
通过POST请求提交表单
xxxxxxxxxx
response = rpa.httpclient.doPost(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
通过POST请求提交表单
xxxxxxxxxx
response = rpa.httpclient.upload(url=url, headers=headers, data=data, files=files)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"data":请求参数,必传,字典类型
"files":上传文件信息,必传,文件对象
返回值说明:
"response":响应报文,字典类型
通过PUT请求获取数据
xxxxxxxxxx
response = rpa.httpclient.doPut(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
通过Deleat请求获取数据
xxxxxxxxxx
response = rpa.httpclient.doDelete(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
通过Head请求获取数据
xxxxxxxxxx
response = rpa.httpclient.doHead(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
通过Options请求获取数据
xxxxxxxxxx
response = rpa.httpclient.doOptions(url=url,headers=headers,params=params)
参数说明:
"url":请求地址,必传,字符串类型
"headers":请求头,必传,字典类型
"params":请求参数,必传,字典类型
返回值说明:
"response":响应报文,字典类型
发送邮件
xxxxxxxxxx
rpa.smtp.send(smtpObj=smtpObj,from_addr='xxx@163.com', to_addrs=['429240967@qq.com'], subject='hello',context='world', filepath='c:\desktop\1.txt')
参数说明:
"smtpObj":邮箱对象,必传
"from_addr":发送方邮箱,必传,字符串类型
"to_addrs":接收方邮箱列表,必传,列表类型
"subject":标题,必传,字符串类型
"context":内容,必传,字符串类型
"filepath":附件路径,必传,字符串类型
返回值说明:
无返回值
连接邮箱
xxxxxxxxxx
smtp_obj = rpa.smtp.connect(host='xxx@163.com',port=25,mail_user='admin',mail_pass='123456')
参数说明:
"host":host地址,必传,字符串类型
"port":端口,必传,字符串类型
"mail_user":用户名,必传,字符串类型
"mail_pass":密码,必传,字符串类型
返回值说明:
"smtp_obj":邮箱对象
断开邮箱连接
xxxxxxxxxx
rpa.smtp.disconnect(smtplib=smtpObj)
参数说明:
"smtplib":邮箱对象,必传
返回值说明:
无返回
连接FTP服务器
xxxxxxxxxx
ftp_obj = rpa.ftp.connectFTPServer(ip='0.0.0.0', port=80, username='aaa', password='bbbbb')
参数说明:
"ip":服务器地址,必传,字符串类型
"port":服务器端口,必传,数字类型
"username":用户名,必传,字符串类型
"password":登录密码,必传,字符串类型
返回值说明:
"ftp_obj":ftp对象
在连接到的服务器当中创建文件夹
xxxxxxxxxx
result = rpa.ftp.mkd(ftp=ftpconnect, pathname='/aaa')
参数说明:
"ftp":ftp对象,必传
"pathname":远程文件夹名称,必传,字符串类型
返回值说明:
"result":创建成功返回全路径,创建失败返回''
列举远程目录下的内容
xxxxxxxxxx
files = rpa.ftp.nlst(ftp=ftpconnect, path=None)
参数说明:
"ftp":ftp对象,必传
"path":远程目录名称,必传,字符串类型
返回值说明:
"info":返回目录下的文件清单,列表类型
判断远程文件是否存在
xxxxxxxxxx
flag = rpa.ftp.exists(ftp=ftpconnect, filename='/aaa/aaa.txt')
参数说明:
"ftp":ftp对象,必传
"filename":文件夹名称,必传,字符串类型
返回值说明:
"flag":存在标志,True存在,False不存在
从服务器下载指定文件并保存
xxxxxxxxxx
rpa.ftp.downloadFile(ftp=ftpconnect, remotePath='/aaa/aaa.txt', localPath='D:/aaa/aaa.txt')
参数说明:
"ftp":ftp对象,必传
"remotePath":远程文件夹名称,必传,字符串类型
"localPath":本地文件夹名称,必传,字符串类型
返回值说明:
无返回值
从本地上传文件至远程服务器
xxxxxxxxxx
rpa.ftp.uploadFile(ftp=ftpconnect, remotePath='/aaa/aaa.txt', localPath='D:/aaa/aaa.txt')
参数说明:
"ftp":ftp对象,必传
"remotePath":远程文件夹名称,必传,字符串类型
"localPath":本地文件夹名称,必传,字符串类型
返回值说明:
无返回值
从远程服务器删除文件
xxxxxxxxxx
rpa.ftp.delete(ftp=ftpconnect, filename='/aaa/aaa.txt')
参数说明:
"ftp":ftp对象,必传
"filename":远程文件名称,必传,字符串类型
返回值说明:
无返回值
关闭远程服务器连接
xxxxxxxxxx
rpa.ftp.quit(ftp=ftpconnect)
参数说明:
"ftp":ftp对象,必传
返回值说明:
无返回值
连接数据库
xxxxxxxxxx
db_obj = rpa.db.connect(type='mysql', host='192.168.1.1',port=80, user='admin', password='123456', database='test')
参数说明:
"type":数据库类型,必传,字符串类型(目前支持mysql、db2)
"host":ip地址,必传,字符串类型
"port":端口,必传,字符串类型
"user":用户名,必传,字符串类型
"password":密码,必传,字符串类型
"database":数据库名称,必传,字符串类型
返回值说明:
"db_obj":数据库对象
SQL查询
xxxxxxxxxx
result = rpa.db.query(type='mysql',db=db, sql='select * from test limit 1')
参数说明:
"type":数据库类型,必传,字符串类型(目前支持mysql、db2)
"db":数据库对象
"sql":SQL语句,必传,字符串类型
返回值说明:
"result":查询结果集,列表类型
SQL插入更新
xxxxxxxxxx
rpa.db.update(type='mysql',db=db, sql='update test set user = "123"')
参数说明:
"type":数据库类型,必传,字符串类型(目前支持mysql、db2)
"db":数据库对象
"sql":SQL语句,必传,字符串类型
返回值说明:
无返回值
SQL删除
xxxxxxxxxx
rpa.db.delete(type='mysql',db=db, sql='delete from test where 1 = 1')
参数说明:
"type":数据库类型,必传,字符串类型(目前支持mysql、db2)
"db":数据库对象
"sql":SQL语句,必传,字符串类型
返回值说明:
无返回值
SQL批量执行
xxxxxxxxxx
update_cmd = 'update table set column1=%s, column2=%s where column3=%s'
data = []
info = rpa.db.batch(type='mysql',db=db, sql=update_cmd, data =data)
参数说明:
"type":数据库类型,必传,字符串类型(目前支持mysql、db2)
"db":数据库对象,必传
"sql":SQL语句,必传,字符串类型
"data":数据,非必传,默认None,列表或者元组类型
返回值说明:
无返回值
提交
xxxxxxxxxx
rpa.db.commit(db=db)
参数说明:
"db":数据库对象,必传
返回值说明:
无返回值
回滚
xxxxxxxxxx
rpa.db.rollback(db=db)
参数说明:
"db":数据库对象,必传
返回值说明:
无返回值
关闭连接
xxxxxxxxxx
rpa.db.close(db=db)
参数说明:
"db":数据库对象,必传
返回值说明:
无返回值
将JSON字符串转换为对象并返回JSON对象
xxxxxxxxxx
json = rpa.mrjson.loads(json_str='{"name": "abc", "age": 1}')
参数说明:
"json_str":JSON字符串,必传
返回值说明:
"json":JSON对象
将JSON对象转换为JSON字符串并返回JSON字符串
xxxxxxxxxx
info = rpa.mrjson.dumps(data={'name': 'abc', 'age': 1})
参数说明:
"data":JSON对象,必传
返回值说明:
"info":JSON字符串
读取JSON文件并将读取到的文件转换为JSON对象
xxxxxxxxxx
json = rpa.mrjson.fromFile(file='test.json')
参数说明:
"file":JSON文件全路径,必传,字符串类型
返回值说明:
"json":JSON对象
对象保存至JSON文件
xxxxxxxxxx
info = rpa.mrjson.toFile(data={'name': 'abc', 'age': 1},file='test.json')
参数说明:
"data":JSON对象,必传
"file":保存的文件,必传,字符串类型
返回值说明:
"info":json字符串
将字符串首字符转换为大写,并返回转换后的值
xxxxxxxxxx
info = rpa.mrstr.capitalize(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"info":转换后的值。
将字符串全部转换为小写并返回转换后的值
xxxxxxxxxx
info = rpa.mrstr.casefold(var = 'Hello World')
参数说明:
"var":字符串,必传
返回值说明:
"info":转换后的值。
返回某个字符在字符串中出现的次数
xxxxxxxxxx
count = rpa.mrstr.count(var = 'hello world', var1 = 'w')
参数说明:
"var":字符串,必传
"var1":指定字符,必传
返回值说明:
"count":出现的次数。
以指定的格式编码字符串
xxxxxxxxxx
info = rpa.mrstr.encode(var = 'hello world', encoding = 'utf-8')
参数说明:
"var":字符串,必传
"encoding":编码格式,非必传,默认ascii
返回值说明:
"info":编码后的字符串
判断字符串的结尾是否为指定值
xxxxxxxxxx
flag = rpa.str.endswith(var = 'hello world', var1 = 'd')
参数说明:
"var":字符串,必传
"var1":指定字符,必传
返回值说明:
"flag":如果字符串以指定值结尾,则返回 True。否则为 False。
在字符串中搜索指定值
xxxxxxxxxx
idx = rpa.str.index(var = 'hello world', var1 = 'd')
参数说明:
"var":字符串,必传
"var1":指定字符,必传
返回值说明:
"idx":指定值在字符串中出现的位置。
判断字符串中是否全部是字母或数字
xxxxxxxxxx
flag = rpa.str.isalnum(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是字母或数字,则返回 True。否则为 False
判断字符串中所有字符是否都在字母表中
xxxxxxxxxx
flag = rpa.str.isalpha(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都在字母表中,则返回 True。否则为 False
判断字符串中所有字符是否都是十进制字符
xxxxxxxxxx
flag = rpa.mrstr.isdecimal(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是十进制字符,则返回 True。否则为 False
判断字符串中所有字符是否为整数
xxxxxxxxxx
flag = rpa.mrstr.isdigit(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符为整数,则返回 True。否则为 False
判断字符串中所有字符是否为标识符
xxxxxxxxxx
flag = rpa.mrstr.isidentifier(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符为标识符,则返回 True。否则为 False
判断字符串中所有字符是否都是小写
xxxxxxxxxx
flag = rpa.mrstr.islower(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是小写,则返回 True。否则为 False
判断字符串中所有字符是否都是数字
xxxxxxxxxx
flag = rpa.mrstr.isnumeric(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是小写,则返回 True。否则为 False
判断字符串中所有字符是否都可打印
xxxxxxxxxx
flag = rpa.mrstr.isprintable(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都可打印,则返回 True。否则为 False
判断字符串中所有字符是否都是空格
xxxxxxxxxx
flag = rpa.mrstr.isspace(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是空格,则返回 True。否则为 False
判断字符串中所有字符是否都是大写
xxxxxxxxxx
flag = rpa.mrstr.isupper(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"flag":如果字符串中的所有字符都是大写,则返回 True。否则为 False
将字符串转换为小写
xxxxxxxxxx
info = rpa.mrstr.lower(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"info":转换后的值
替换指定字符串
xxxxxxxxxx
info = rpa.mrstr.replace(var = 'hello world', var1 = 'h', var2 = 'd')
参数说明:
"var":字符串,必传
"var1":需替换的字符,必传
"var2":替换为的字符,必传
返回值说明:
"info":转换后的值
在指定的分隔符处拆分字符串
xxxxxxxxxx
info = rpa.mrstr.split(var = 'hello world', var1 = 'h')
参数说明:
"var":字符串,必传
"var1":分隔符,必传
返回值说明:
"info":拆分后的列表
判断字符串是否以指定值开头
xxxxxxxxxx
flag = rpa.mrstr.startswith(var = 'hello world', var1 = 'h')
参数说明:
"var":字符串,必传
"var1":指定值,必传
返回值说明:
"flag":如果字符串以指定值开头,则返回 True。否则为 False
交换大小写,小写变成大写,反之亦然
xxxxxxxxxx
info = rpa.mrstr.swapcase(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"info":交换后的值。
将字符串转换为大写
xxxxxxxxxx
info = rpa.mrstr.upper(var = 'hello world')
参数说明:
"var":字符串,必传
返回值说明:
"info":转换后的值。
正则表达式查找子串
xxxxxxxxxx
info = rpa.reg.find(pattern='www', string='www.baidu.com', flags=0)
参数说明:
"pattern":匹配的正则表达式,必传
"string":要匹配的字符串,必传
"flags":标志位,非必传,用于控制正则表达式的匹配方式(默认为0)
0:无任何标识
2:使匹配对大小写不敏感
4:做本地化识别(locale-aware)匹配
8:多行匹配,影响 ^ 和 $
16:匹配包括换行在内的所有字符
32:根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.
64:该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解。
返回值说明:
"info":匹配后结果
正则表达式查找全部子串
xxxxxxxxxx
info = rpa.reg.findall(pattern='d+', string='runoob 123 google 456', flags=0)
参数说明:
"pattern":匹配的正则表达式,必传
"string":要匹配的字符串,必传
"flags":标志位,非必传,用于控制正则表达式的匹配方式(默认为0)
0:无任何标识
2:使匹配对大小写不敏感
4:做本地化识别(locale-aware)匹配
8:多行匹配,影响 ^ 和 $
16:匹配包括换行在内的所有字符
32:根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.
64:该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解。
返回值说明:
"info":匹配后结果
正则表达式替换
xxxxxxxxxx
info = rpa.reg.sub(pattern='D', repl='', string='2004-959-559 # 这是一个电话号码', count=0, flags=0)
参数说明:
"pattern":正则中的模式字符串,必传
"repl":替换的字符串,也可为一个函数,必传
"string":要被查找替换的原始字符串,必传
"count":模式匹配后替换的最大次数,非必传,默认0,表示替换所有的匹配
"flags":标志位,用于控制正则表达式的匹配方式(默认为0)
0:无任何标识
2:使匹配对大小写不敏感
4:做本地化识别(locale-aware)匹配
8:多行匹配,影响 ^ 和 $
16:匹配包括换行在内的所有字符
32:根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.
64:该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解。
返回值说明:
"info":替换后结果
生成一个数学常量
xxxxxxxxxx
info = rpa.mrmath.constant(const='pi')
参数说明:
"const":参数列表,必传
"pi":圆周率π
"tau":圆周常数Tau(2π)
"e":自然常数e
"inf":浮点数无穷大inf
"nan":非数值nan
返回值说明:
"info":数字常量
进行加减乘除等基本运算
xxxxxxxxxx
info = rpa.mrmath.base(flag='add', x1=0, x2=0)
参数说明:
"flag":参数列表
"add":加法
"minus":减法
"multiply":乘法
"divide":除法
"integer":除法取整
"remainder":除法取余
"abs":取绝对值
"negative":去负值
"power":取次幂
"x1":数值表达式,可以是整数,浮点数,复数
"x2":数值表达式,可以是整数,浮点数,复数
返回值说明:
"info":运算结果
进行进制转化
xxxxxxxxxx
info = rpa.mrmath.pow(flag='bin', x=0)
参数说明:
"flag":参数列表
"bin":二进制
"oct":八进制
"hex":十六进制
"x":十进制数字
返回值说明:
"info":转化结果
通用函数
xxxxxxxxxx
info = rpa.mrmath.common(*args=(1,2),flag='ceil')
参数说明:
"flag":参数列表
"ceil":获取大于或等于输入值的最小整数(向上取整)
"floor":获取小于或等于输入值的最大整数(向下取整)
"fabs":获取输入值的绝对值
"factorial":获取输入值的阶乘
"gcd":获取输入值x和y的最大公约数
"modf":获取输入值的小数和整数部分
"fmod":获取输入值x对y取模,x-n*y其中n=math.floor(x/y)
"remainder": 获取输入值x相对于y的余数,x-n*y其中n=math.ceil(x/y)
"copysign":获取输入值x的绝对值和输入值y的符号
"frexp":返回一个元组(x,y),使得输入值=x*2**y
"ldexp":根据输入值x和y,返回x*(2**y)
"fsum": 返回可迭代对象中的迭代和,当数值为浮点数时候,推荐使用
"trunc": 返回输入值x的整数部分
"isclose":若 a 和 b 的值比较接近则返回 True,否则返回 False。根据给定的绝对和相对容差确定两个值是否被认为是接近的。
"rel_tol":是相对容差 —— 它是 a 和 b 之间允许的最大差值,相对于 a 或 b 的较大绝对值。例如,要设置5%的容差,请传递 rel_tol=0.05 。
默认容差为 1e-09,确保两个值在大约9位十进制数字内相同。 rel_tol 必须大于零。abs_tol 是最小绝对容差 —— 对于接近零的比较很有用。 abs_tol 必须至少为零
"isfinite": 判断输入值是否是有限数值
"isinf": 判断输入值是否是正或者负无穷
"isnan": 判断输入值是否是非数值类型
"*args":存储变量,元组类型
返回值说明:
"info":对应通用函数值
幂/对数函数
xxxxxxxxxx
info = rpa.mrmath.expLog(flag='exp', x=0, y=0)
参数说明:
"flag":参数列表
"exp":获取e的x次幂
"expm1":获取e的x次幂减1
"log":获取x的对数,默认底为e
"log1p":获取1加x的自然对数(底为e)
"log2":获取x以2的对数,比math.log(x,2)更加精确
"log10":获取x以10的对数,比math.log(x,10)更加精确
"pow":获取x的y次幂,math.pow(2,3)
"sqrt":获取x的平方根,math.sqrt(8)
"x":变量x,数字类型
"y":变量y,数字类型
返回值说明:
"info":对应函数值
三角函数
xxxxxxxxxx
info = rpa.mrmath.trigonometric(flag='acos', x=0, y=0)
参数说明:
"flag":
"acos":以弧度为单位返回x的反余弦值
"asin":以弧度为单位返回x的反正弦值
"atan":以弧度为单位返回x的反正切值
"atan2":以弧度为单位返回x/y的反余弦值
"cos":返回x弧度的余弦值
"sin":返回x弧度的正弦值
"tan":返回x弧度的正切值
"hypot":返回原点到(x,y)的欧式距离,等于math.sqrt(x*x + y*y)
"x":变量x,数字类型
"y":变量y,数字类型
返回值说明:
"info":对应函数值
角度转换
xxxxxxxxxx
info = rpa.mrmath.degree(flag='degrees', x=0)
参数说明:
"flag":参数列表
"degrees": 弧度转度数
"radians":度数转弧度
"x":变量x,数字类型
返回值说明:
"info":对应的角度转换值
双曲函数
xxxxxxxxxx
info = rpa.mrmath.hyperbolic(flag='acosh', x=0)
参数说明:
"flag":参数列表
"acosh":返回x的反双曲余弦值
"asinh":返回x的反双曲正弦值
"atanh":返回x的反双曲正切值
"cosh":返回x的双曲余弦值
"sinh":返回x的双曲正弦值
"tanh":返回x的双曲正切值
"x":变量x,数字类型
返回值说明:
"info":对应双曲函数的值
特殊函数
xxxxxxxxxx
info = rpa.mrmath.getRounding(flag='erf', x=0)
参数说明:
"flag":参数列表
"erf":获取输入值的误差函数
"erfc":获取输入值的互补误差函数
"gamma":获取输入值的伽马函数值
"lgamma":获取伽马函数在输入值x的绝对值的自然对数
"x":变量x,数字类型
返回值说明:
"info":对应特殊函数的值
随机函数
xxxxxxxxxx
info = rpa.mrmath.randomfunc(flag='randint', x=0, y=0)
参数说明:
"flag":参数列表
"randint":生成随机整数
"uniform":生成随机浮点数
"x":随机数的最小值,包含该值
"y":随机数的最大值,包含该值
返回值说明:
"info":生成的随机数
数值转化
xxxxxxxxxx
info = rpa.mrmath.convert(flag='float', x=0)
参数说明:
"flag":参数列表
"int":转为整数
"float":浮点数
"complex":复数
"x":变量x,数字类型
返回值说明:
"info":转化后的值
获取当前时间戳
xxxxxxxxxx
timestamp = rpa.mrtime.getStamp()
参数说明:
无参数
返回值说明:
"timestamp":获取到的当前时间戳
获取当前时间
xxxxxxxxxx
time = rpa.mrtime.getTimes()
参数说明:
无参数
返回值说明:
"time":获取到的当前时间
获取T+n的时间
xxxxxxxxxx
info = rpa.mrtime.the_other_day(day = 1)
参数说明:
"day":n的值
返回值说明:
"info":获取到的T+n的时间
获取当前日期
xxxxxxxxxx
curDate = rpa.mrtime.getDate()
参数说明:
无参数
返回值说明:
"curDate":获取到的当前日期
格式化时间
xxxxxxxxxx
info = rpa.mrtime.fromatTime(date=date, timeformat=timeformat, newtimeformat=newtimeformat)
参数说明:
"date":带转换时间字符串,必传,字符串类型
"timeformat":需要转换时间字符串的日期格式,必传,字符串类型
"newtimeformat":转换后时间字符串的日期格式,必传,字符串类型
返回值说明:
"info":转换后的时间字符串
获取年份
xxxxxxxxxx
info = rpa.mrtime.getYear()
参数说明:
无参数
返回值说明:
"info":当前年份
获取月份
xxxxxxxxxx
info = rpa.mrtime.getMonth()
参数说明:
无参数
返回值说明:
"info":当前月份
获取当前是每个月第几天
xxxxxxxxxx
info = rpa.mrtime.getDay()
参数说明:
无参数
返回值说明:
"info":当前天数
获取当前小时数
xxxxxxxxxx
info = rpa.mrtime.getHour()
参数说明:
无参数
返回值说明:
"info":当前小时数
获取当前分钟数
xxxxxxxxxx
info = rpa.time.getMinute()
参数说明:
无参数
返回值说明:
"info":当前分钟数
获取当前秒数
xxxxxxxxxx
info = rpa.time.getSeconds()
参数说明:
无参数
返回值说明:
"info":当前秒数
获取今天是本周第几天
xxxxxxxxxx
info = rpa.time.getWeek()
参数说明:
无参数
返回值说明:
"info":今天是本周第几天
计算两个时间差
xxxxxxxxxx
difference = rpa.mrtime.difference(time1=time1, time2=time2, timeformat=timeformat)
参数说明:
"time1":第一个时间字符串
"time2":第二个时间字符串
"timeformat":两个时间字符串格式
返回值说明:
"difference":两个时间差(单位秒),值为int类型
计算天数差(取绝对值)
xxxxxxxxxx
differ = rpa.mrtime.differ_day(time1=time1, time2=time2, timeformat=timeformat)
参数说明:
"time1":第一个时间字符串,必传
"time2":第二个时间字符串,必传
"timeformat":两个时间字符串的日期格式,必传
返回值说明:
"differ":计算后的天数差(取绝对值)
字符串转时间格式
xxxxxxxxxx
format_time = rpa.mrtime.strToTime(timestr=timestr, timeformat=timeformat)
参数说明:
"timestr":第一个时间字符串
"timeformat":时间字符串日期格式
返回值说明:
"format_time":格式化后的时间
识别二维码图片
xxxxxxxxxx
info = rpa.mrqrcode.identifyqrcode(file='test.jpg')
参数说明:
"file":二维码图片路径,必传,字符串类型
返回值说明:
"info":二维码内容,列表类型
生成二维码图片
xxxxxxxxxx
rpa.mrqrcode.createqrcode(data='1234', file='test.jpg')
参数说明:
"data":向二维码添加的数据,可以是数字、文本、URL
"file":生成的二维码图片路径,必填
返回值说明:
无返回值
获取并返回html对象
xxxxxxxxxx
html_obj = rpa.parseHtml.getHtmlObj(html=html)
参数说明:
"html":html对象,非必传,默认None
返回值说明:
"html_obj":html对象
解析html并返回表格列表
xxxxxxxxxx
table_objs = rpa.parseHtml.getTables(html=html)
参数说明:
"html":要解析的网页源码字符串,非必传,默认None
返回值说明:
"table_objs":表格对象,列表类型
提取图片数据
xxxxxxxxxx
image_objs = rpa.parseHtml.getImages(html=html)
参数说明:
"html":要解析的网页源码字符串,非必传,默认None
返回值说明:
"image_objs":图片路径列表
解析html并下载图片数据
xxxxxxxxxx
rpa.parseHtml.downloadImg(html=html, picpath=r'C:ImageDownload', picFormat='jpg')
参数说明:
"html":要解析的网页源码字符串,非必传,默认None
"picpath":图片保存路径,必传
"picFormat":下载图片格式,必传
返回值说明:
无返回值