def download_stay_picinfo(): #Downloads picture locally as jpg img, MIGHT be useful if we are doing local image classification....but I rather gcloud classify with url if needed print('Extracting Top 5 Stay Information..') url=[] url=get_stay_url() print('Downloading Pics uploaded by host..') i=0 k=0 while (i<5): r.url(url[i+k]) r.click('//*[@id="FMP-target"]') j=0 while (1): j=j+1 print(f'Downloading Homestay {i+1} Photo {j}') r.wait(0.4) #r.snap('//div[@data-testid="photo-viewer-slideshow-desktop"]/div/div/div/div/div/img',f"data/{i+1}/{j}.jpg") #fastest but not perfect if (r.exist('//div[@data-testid="photo-viewer-slideshow-desktop"]/div/div/div/div/div/img/@src') == True): dl_link=r.read('//div[@data-testid="photo-viewer-slideshow-desktop"]/div/div/div/div/div/img/@src') r.download(dl_link,f'data/{i+1}/{j}.jpg') print(f'Homestay {i+1} Photo {j} downloaded!') else: i=i-1 #Detects Whales (Airbnb Plus spoils the format alot) k=k+1 #Compensating Constant k print("WHALE detected, adding one more loop..") if (r.exist('/html/body/div[9]/div/div/div/div/div[3]/div/div[2]/button') == False or j >= 15): break #Max 15 photos r.click('/html/body/div[9]/div/div/div/div/div[3]/div/div[2]/button') i=i+1 r.click('/html/body/div[9]/div/div/div/section/div/div[1]/div/button') print('Done.')
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 download_workbook(file_name): r.download('http://rpachallenge.com/assets/downloadFiles/challenge.xlsx', f'{file_name}') return file_name
# http://www.rpachallenge.com/ import rpa import pyautogui import pandas import os rpa.init() rpa.url('http://www.rpachallenge.com/') pyautogui.sleep(7) janela = pyautogui.getActiveWindow() janela.maximize() rpa.download('http://www.rpachallenge.com/assets/downloadFiles/challenge.xlsx', 'desafio.xlsx') pyautogui.sleep(2) dados = pandas.read_excel('desafio.xlsx', sheet_name='Sheet1') colunas = [ 'First Name', 'Last Name ', 'Company Name', 'Role in Company', 'Address', 'Email', 'Phone Number' ] data_frame = pandas.DataFrame(dados, columns=colunas) for row in data_frame.itertuples(): print(row) rpa.type('//*[@ng-reflect-name="labelFirstName"]', row[1]) rpa.type('//*[@ng-reflect-name="labelLastName"]', row[2])
import rpa as r from openpyxl import load_workbook r.init() #Inicialization r.url('http://www.rpachallenge.com') # Access URL r.download('http://www.rpachallenge.com/assets/downloadFiles/challenge.xlsx', 'challenge.xlsx') # Download File wb = load_workbook(filename='challenge.xlsx', read_only=True) # Open file ws = wb.active r.type('Start', '[enter]') lista = [ "FirstName", "LastName", "CompanyName", "Role", "Address", "Email", "Phone" ] for i in range(2, 12): cont = 0 for j in range(1, 8): cell_obj = ws.cell(row=i, column=j) r.type("//*[@ng-reflect-name=\"label{}\"]".format(lista[cont]), str(cell_obj.value)) cont += 1 r.type('submit', '[enter]')