def initialize(): print('Initializing...') r.init() r.url(URL) if r.exist('//*/button[@type="submit"]') == True: r.click('//*/button[@type="submit"]') # Anti RPA by AirBnB print('Done.')
def get_rpa(timeout=10): r.init() r.url('https://www.google.com') r.type('//*[@name="q"]', 'decentralization[enter]') print(r.read('result-stats')) r.snap('page', 'results.png') r.close()
def main(): r.init() r.url('https://www.hattrick.org/zh/') r.type('ctl00_CPContent_ucLogin_txtUserName', 'ccforever') r.type('ctl00_CPContent_ucLogin_txtPassword', 'cc0323') r.click('ctl00_CPContent_ucLogin_butLogin') r.wait('10') r.click('myClubLink')
def today_dollar(): r.init() r.url('https://www.melhorcambio.com/dolar-hoje') sleep(4) dolar = r.read('//*[@id="comercial"]') sleep(2) print(f'{dolar} | {datetime.today()}') r.close() return dolar
def acoe(): r.init(visual_automation=True) r.url("https://acoe.annauniv.edu/rusa/login/student") # rollNo = r.ask("enter roll number") r.type("input", "2018103549") r.type("password", "Amiami@143[enter]") r.dclick("login")
def initialize(): print('Initializing...') r.init() r.timeout(15) #set timeout to wait longer r.url(URL) while r.exist('//*/button[@type="submit"]') == False: r.url(URL) print("Wrong page detected, retrying..") r.click('//*/button[@type="submit"]') # Anti RPA by AirBnB print('Done.')
def faceBook(): r.init(visual_automation=True) r.url("https://www.facebook.com") r.dclick("email") userName = r.ask("Enter the User Name") r.type("email", userName) password = r.ask("Enter the password") r.type("pass", password + "[enter]")
def logout(): r.init(visual_automation=True, chrome_browser=False) r.run('C:\Servyou\EPPortal_DS3.0\EPEvenue_SH.exe') if r.exist("a.png"): r.click("a.png") r.click("b.png") r.click("c.png") # 13s pass
def hackerrank(): r.init(visual_automation=True) r.url("https://www.hackerrank.com/dashboard") r.dclick(".login.pull-right.btn.btn-dark.btn-default.mmT") r.dclick("input-1") userName = r.ask("Enter the User Name") r.type("input-1", userName) password = r.ask("Enter the password") r.type("input-2", password + "[enter]")
def dollar_cannadian(): r.init() r.url('https://www.melhorcambio.com/dolar-hoje') sleep(4) r.click('//*[@id="dock"]/ul/li[2]/a') sleep(4) dolar_c = r.read('//*[@id="comercial"]') sleep(2) print(f'{dolar_c} | {datetime.today()}') r.close() return dolar_c
def do_web_auto(search_data): r.init() r.url('https://www.google.com') r.click('.gLFyf.gsfi') r.type('.gLFyf.gsfi', f'{search_data}[enter]') #r.type("//*[@name='q']', 'decentralization[enter]") #print(r.read('result-stats')) r.snap('page', 'results.png') res = r.read('result-stats') r.close() return res
def carrefuorRegisterRpa(cnpj, customerFirstName, customerLastName, displayName, companyName, registrationMunicipal, registrationState, category, platform, loginEmail, phone): url = 'https://www.carrefour.com.br/marketplace/inscreva-se' r.init() r.url(url) time.sleep(10) r.click('//*[@id="onetrust-accept-btn-handler"]') time.sleep(3) r.click('//*[@id="00N6g00000RpFD9"]') r.click('//*[@id="00N6g00000RpFD9"]')
def convert_html_to_jpg(): URL = "http://127.0.0.1:5000/get_html" #localhost r.init() r.url(URL) print('Zooming out') r.click('//*[@class="leaflet-control-zoom-out"]') r.click('//*[@class="leaflet-control-zoom-out"]') print('Waiting to load...') r.wait(18) print('Snapping') r.snap('//html/body', "./Images/map.jpg") print('Done.') r.close()
def check(): a = r.init(visual_automation=True, chrome_browser=False) print(a) b = r.run(r'C:\Users\20945\AppData\Local\UB_Store\Store.exe') print(b) r.click(0, 0) r.rclick(0.0) pass
def login(): r.init(visual_automation=True, chrome_browser=False) r.run('E:\soft_isruning_position\WXWork\WXWork.exe') r.click("h.jpg") r.click("3.png") r.wait(1.5) is_true = r.exist("aa.png") print(is_true) if is_true: r.snap( "step-6.png", filename_to_save= r"D:\projects\S_Git_proj\spider\Other\spider_all\Rpa-Python\image") print("截图") print("进行图片传输") r.wait(1.5) is_true = r.exist('step-1.png') if is_true: print("login success") else: print("login fail")
def open_browser(): r.init(True)
import pyautogui as ui import rpa import pandas as pd rpa.init() rpa.url('http://rpachallenge.com/') window = ui.getActiveWindow() window.maximize() ui.sleep(5) rpa.download('http://rpachallenge.com/assets/downloadFiles/challenge.xlsx', 'challenge.xlsx') ui.sleep(2) df = pd.DataFrame(pd.read_excel(r'challenge.xlsx', sheet_name='Sheet1')) rpa.click('/html/body/app-root/div[2]/app-rpa1/div/div[1]/div[6]/button') for row in df.itertuples(): rpa.type('//*[@ng-reflect-name="labelFirstName"]', row[1]) rpa.type('//*[@ng-reflect-name="labelLastName"]', row[2]) rpa.type('//*[@ng-reflect-name="labelCompanyName"]', row[3]) rpa.type('//*[@ng-reflect-name="labelRole"]', row[4]) rpa.type('//*[@ng-reflect-name="labelAddress"]', row[5]) rpa.type('//*[@ng-reflect-name="labelEmail"]', row[6]) rpa.type('//*[@ng-reflect-name="labelPhone"]', str(row[7])) rpa.click('/html/body/app-root/div[2]/app-rpa1/div/div[2]/form/input') ui.sleep(1) ui.sleep(5)
def youtube(): r.init(visual_automation=True) r.url("https://www.youtube.com/") r.dclick("img")
import rpa as r r.init(visual_automation=True, chrome_browser=False) r.keyboard('[cmd][space]') r.keyboard('safari[enter]') r.keyboard('[cmd]t') r.keyboard('joker[enter]') r.wait(2.5) r.snap('page.png', 'results.png') r.close()
import rpa as r r.init(visual_automation=True) r.dclick('outlook_icon.png') r.click('new_mail.png') ... r.type('message_box.png', 'message') r.click('send_button.png') r.close()
def web_page_init(url): r.init() r.wait(2.0) r.url(webpage_url=url)
# NOTE1: the workfile will have more rows and columns than can be seen. it's possible # file was recycled. manually delete those 'hidden' rows and columns # NOTE2: when using lubuntu, LibreOffice Calc will not allow you to resave the file unless # reformatted to .ods. Try editing the file using Gnumeric instead to retain format as .xlsx. # loop through the rows, skip first row as the header, and print for r in range(2, sheet.max_row + 1): for c in range(1, sheet.max_column + 1): cell_obj = sheet.cell(row=r, column=c) print(cell_obj.value, end=',') print() # input the values to the rpachallenge website through web automation # this makes use of xpath (using chrome, inspect the element > right-click on highlighted element > # copy > copy xpath) bot.init() bot.url('http://www.rpachallenge.com') # start the clock bot.click('/html/body/app-root/div[2]/app-rpa1/div/div[1]/div[6]/button') # loop through the records and input onto website for r in range(2, sheet.max_row + 1): # first name bot.type('//*[@ng-reflect-name="labelFirstName"]', sheet.cell(row=r, column=1).value) # last name bot.type('//*[@ng-reflect-name="labelLastName"]', sheet.cell(row=r, column=2).value) # company name bot.type('//*[@ng-reflect-name="labelCompanyName"]', sheet.cell(row=r, column=3).value) # role in company bot.type('//*[@ng-reflect-name="labelRole"]', sheet.cell(row=r, column=4).value) # address bot.type('//*[@ng-reflect-name="labelAddress"]', sheet.cell(row=r, column=5).value)
def urlSnap(): r.init(visual_automation=True) r.url('https://www.google.com') r.type("q", "CEG[enter]") print(r.read('result-stats')) r.snap('page', 'results.png')
import rpa as r import numpy as np import cv2 from PIL import Image import pytesseract from twilio.rest import Client # open browser r.init(True) # go to amazon sign in page r.url( 'https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26action%3Dsign-out%26path%3D%252Fgp%252Fyourstore%252Fhome%26ref_%3Dnav_youraccount_signout%26signIn%3D1%26useRedirectOnSuccess%3D1' ) # sign into amazon account r.type('text', '******[enter]') # enter amazon username here r.type('text', '*******[enter]') # enter password here # click to go to delivery window page r.click('Cart') r.click('Checkout Whole Foods Market Cart') r.click('continue') r.click('continue') r.wait(20) # save screenshot file r.snap('page', 'results.png') # use open to extract delivery availability msg filename = 'results.png' img = cv2.imread(filename) imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # convert to gray filename_gray = filename + '_box.jpg' cv2.imwrite(filename_gray, imgray)
def sigaaRPA(self): r.init() r.timeout(30) while(self.state > 0): if self.terminateBot: r.close() break elif self.state == 1: # use url('your_url') to go to web page, url() returns current URL r.url('https://sigaa.upb.edu.co/ssomanager/c/SSB') self.state = self.state + 1 elif self.state == 2: # use type() to use the keyboard to write something if r.exist(X.username) & r.present(X.username): r.type(X.username, '000290164') r.type(X.password, 'Tandres1997_') self.state = self.state + 1 else: print("Couldn\'t find Username and Password Components") self.state = 1 elif self.state == 3: # use click() to click on an UI element or x, y location self.state = click(X.login, self.state) elif self.state == 4: ## hace click en Estudiantes self.state = click(X.estudiantes, self.state) elif self.state == 5: ## Hace click en Seguimiento a la formación self.state = click(X.seguimieto, self.state) elif self.state == 6: ## hace click en Calificaciones parciales self.state = click(X.calif, self.state) elif self.state == 7: ## Selecciona el semestre del cual quiere mirar las notas r.select(X.semester, self.semester) self.state = self.state + 1 elif self.state == 8: ## se hace click en enviar r.click(X.enviar) self.state = self.state + 1 elif self.state == 9: tablexpath = '' r.wait(2) numCursos = r.count('//*[@class="datadisplaytable"][2]/tbody/tr/td/a') for i in range(2,numCursos+2): tablexpath = '//*[@class="datadisplaytable"][2]/tbody/tr['+ str(i) +']/td/a' if r.exist(tablexpath): r.click(tablexpath) r.wait(1) pagetitle = r.read('//div[@id="pagetitle"]') if pagetitle == 'Detalle de Calificación de Componente': materia = r.read('//*[@class="datadisplaytable"][1]/tbody/tr[5]/td[2]') print(materia) r.snap('page', './notas/s'+self.semester+'/'+ materia +'.png') # r.table('//table[@class="datadisplaytable"][2]', './csv/table'+str(i-1)+'.csv') r.dom('history.back()') # use wait() to wait for a number of seconds # default wait() is 5 seconds r.wait(5) self.terminateBot = True elif self.state == 10: r.dom('history.back()')
import rpa as r r.init() #Inicialization r.url('https://www.w3schools.com/tags/tag_table.asp') # Access URL r.table('w3-table-all notranslate', 'tablewebsite.csv')
def initialize(): r.init() r.url(URL) if r.exist('//*/button[@type="submit"]') == True: r.click('//*/button[@type="submit"]') #Anti RPA by AirBnB
def add(): r.init(visual_automation=True, chrome_browser=False) r.run('E:\soft_isruning_position\WXWork\WXWork.exe') pass
import rpa as r from time import sleep import pyautogui as p r.init() sleep(2) r.url('http://www.google.com') window = p.getActiveWindow() window.maximize() sleep(2) # r.type('//*[@id="tsf"]/div[2]/div[1]/div[1]/div/div[2]/input', 'Imune Kids[enter]') r.type('//*[@name="q"]', 'Imune Kids[enter]') sleep(2) r.snap('page', 'img.png') sleep(2) r.close()
import rpa import pyautogui rpa.init(visual_automation=False, chrome_browser=True) rpa.url('https://www.melhorcambio.com/dolar-hoje') rpa.wait(5.0) janela = pyautogui.getActiveWindow() janela.maximize() rpa.type('//*[@id="original"]', '10') pyautogui.sleep(2) dolar_comercial = rpa.read('//*[@id="comercial"]') pyautogui.sleep(2) print(dolar_comercial) janela.close()