# coding=utf-8
# 编译日期:2020-02-10 22:16:51
# 版权所有:www.i-search.com.cn
import time
import pdb
from ubpa.ilog import ILog
from ubpa.base_img import *
import getopt
from sys import argv
import sys
import ubpa.iexcel as iexcel
import ubpa.iie as iie
import ubpa.itools.rpa_str as rpa_str
class Prg1:
def __init__(self,**kwargs):
self.__logger = ILog(__file__)
self.path = set_img_res_path(__file__)
self.robot_no = ''
self.proc_no = ''
self.job_no = ''
self.input_arg = ''
if('robot_no' in kwargs.keys()):
self.robot_no = kwargs['robot_no']
if('proc_no' in kwargs.keys()):
self.proc_no = kwargs['proc_no']
if('job_no' in kwargs.keys()):
self.job_no = kwargs['job_no']
if('input_arg' in kwargs.keys()):
self.input_arg = kwargs['input_arg']
self.input_arg = self.input_arg.replace("\\","/")
def MailLogin(self,pv_1=None):
mail_pwd='EyMzQ1NiojIypBYmNkQD'
#网站
self.__logger.debug('Flow:MailLogin,StepNodeTag:0711234021427,Note:')
iie.open_url(url='mail.163.com')
# 鼠标点击
self.__logger.debug('Flow:MailLogin,StepNodeTag:0711465354417,Note:')
iie.do_click_pos(win_title=r'163网易免费邮--中文邮箱第一品牌 - Internet Explorer',url=r'https://mail.163.com/',selector=r'#switchAccountLogin',button=r'left',curson=r'center',times=1,run_mode=r'unctrl',waitfor=10,scroll_view='no')
time.sleep(10)
# 设置文本
self.__logger.debug('Flow:MailLogin,StepNodeTag:0711255740732,Note:输入用户名')
iie.set_text(title=r'URS组件',selector=r'#auto-id-1581047288741',text=r'sangerhoo',waitfor=10)
# 设置文本
self.__logger.debug('Flow:MailLogin,StepNodeTag:0711265542834,Note:输入邮箱密码')
iie.set_text(title=r'URS组件',selector=r'#auto-id-1581047288744',text=mail_pwd,waitfor=10)
# 鼠标点击
self.__logger.debug('Flow:MailLogin,StepNodeTag:0711395419011,Note:登录')
time.sleep(10)
iie.do_click_pos(win_title=r'163网易免费邮--中文邮箱第一品牌 - Internet Explorer',title=r'URS组件',selector=r'#dologin',button=r'left',curson=r'center',times=1,run_mode=r'unctrl',waitfor=10,scroll_view='no')
def Main(self):
FirstResult=None
lv_3=None
lv_2=None
lv_1=None
#网站
self.__logger.debug('Flow:Main,StepNodeTag:062302544737,Note:运行IE ')
iie.open_url(url='https://baike.baidu.com/')
# 设置文本
self.__logger.debug('Flow:Main,StepNodeTag:071105234477,Note:')
iie.set_text(url=r'https://baike.baidu.com/',selector=r'#query',text=r'外汇管理局',waitfor=10)
# 鼠标点击
self.__logger.debug('Flow:Main,StepNodeTag:071107248399,Note:')
iie.do_click_pos(win_title=r'百度百科_全球最大中文百科全书 - Internet Explorer',url=r'https://baike.baidu.com/',selector=r'#searchLemma',button=r'left',curson=r'center',times=1,run_mode=r'unctrl',waitfor=10,scroll_view='no')
# 获取文本
self.__logger.debug('Flow:Main,StepNodeTag:0712022298823,Note:')
FirstResult = iie.get_text(url=r'https://baike.baidu.com/search?word=%E5%A4%96%E6%B1%87%E7%AE%A1%E7%90%86%E5%B1%80&pn=0&rn=0&enc=utf8',selector=r'#body_wrapper > DIV:nth-of-type(1) > DL:nth-of-type(1) > DD:nth-of-type(1)',waitfor=10)
#输出
self.__logger.debug('Flow:Main,StepNodeTag:071512398492,Note:')
rpa_str.iprint(param=FirstResult)
#单元格写入
self.__logger.debug('Flow:Main,StepNodeTag:071513538064,Note:')
iexcel.write_cell(path='E:/RPA/Test/Prg1/Prg1/result/rst.xlsx',text=FirstResult,file_type='excel')
if __name__ == '__main__':
robot_no = ''
proc_no = ''
job_no = ''
input_arg = ''
try:
argv = sys.argv[1:]
opts, args = getopt.getopt(argv,"hr:p:j:i:",["robot = ","proc = ","job = ","input = "])
except getopt.GetoptError:
print ('robot.py -r <robot> -p <proc> -j <job>')
for opt, arg in opts:
if opt == '-h':
print ('robot.py -r <robot> -p <proc> -j <job>')
elif opt in ("-r", "--robot"):
robot_no = arg
elif opt in ("-p", "--proc"):
proc_no = arg
elif opt in ("-j", "--job"):
job_no = arg
elif opt in ("-i", "--input"):
input_arg = arg
pro = Prg1(robot_no=robot_no,proc_no=proc_no,job_no=job_no,input_arg=input_arg)
pro.Main()
___logger = ILog(__file__)
___logger.debug('Class:Main,ProTag:Quit,Note:Exit')
评论0