def extract_table_from_page(next_image): for count in range(1, 4): if count == 1: r.table('//*[@id="tableSandbox"]', 'temp.csv') extrc_table = pd.read_csv('temp.csv') extrc_table.to_csv(r'webtable.csv', mode='a', index=None, header=True) move_to_center_img_click(next_image, 0.7) else: r.table('//*[@id="tableSandbox"]/tbody', 'temp.csv') extrc_table = pd.read_csv('temp.csv') extrc_table.to_csv(r'webtable.csv', mode='a', index=None, header=True) move_to_center_img_click(next_image, 0.7)
import rpa as r import pyautogui as p import pandas as pd import os as o r.init() r.url('https://rpachallengeocr.azurewebsites.net/') p.sleep(7) count_page = 1 while count_page <= 3: r.table('//*[@id="tableSandbox"]', 'temp.csv') data_csv = pd.read_csv('temp.csv') if count_page == 1: data_csv.to_csv(r'webTable.csv', mode='a', index=None, header=True) else: data_csv.to_csv(r'webTable.csv', mode='a', index=None, header=False) r.click('//*[@id="tableSandbox_next"]') count_page += 1 r.close() o.remove('temp.csv') csv_xlsx = pd.read_csv(r'webTable.csv') csv_xlsx.to_excel(r'converted_to_xls.xlsx')
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')
from email.mime.base import MIMEBase from email import encoders import mimetypes # путь к текущей папке скрипта scr_dir = path.dirname(path.abspath(__file__)) # пути к csv файлам csv_file_usd = scr_dir + r'\table_usd.csv' csv_file_eu = scr_dir + r'\table_eu.csv' # пути к xlsx файлам xlsx_file_out = scr_dir + r'\table.xlsx' r.init(visual_automation = True) r.url('https://yandex.ru/news/quotes/2002.html') r.table('quote__data', csv_file_usd) r.url('https://yandex.ru/news/quotes/2000.html') r.table('quote__data', csv_file_eu) r.close() workbook = Workbook() sheet = workbook.active # финансовый рублёвый формат cell_format = u'# ##0.00 ₽;[RED]-# ##0.00 ₽' # числовой формат num_format = u'# ##0.00;[RED]-# ##0.00'