def crediteuropebank(): STARTING_URL = "http://www.crediteurope.ro/dobanzi-cotatii-si-cursuri/cursuri/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td/text()") contor = 0 marire = 0 prescurtari = ["EUR", "CHF", "USD", "GBP", "JPY", "SEK"] list_contor = 0 while contor < 25: if contor == 16: marire = 1 else: marire = 0 datainput.main( prescurtari[list_contor], str(z[contor]), str(z[contor + 2 + marire]), str(z[contor + 3 + marire]), "CreditEuropeBank", data_de_azi, ) # print prescurtari[list_contor], z[contor], z[contor + 2 + marire], z[contor + 3 + marire] contor = contor + 4 + marire list_contor = list_contor + 1
def carpaticabank(): STARTING_URL = "https://www.carpatica.ro/curs-valutar/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr[position()<7 and position()>2]/td[position()<5]/text()") contor = 0 while contor < len(z): numar, nume = str(z[contor]).split() datainput.main(nume, nume, str(z[contor + 1]).strip(), str(z[contor + 2]).strip(), "CarpaticaBank", data_de_azi) # print nume, nume, z[contor + 1].strip(), z[contor + 2].strip(), 'CarpaticaBank', data_de_azi contor = contor + 3
def brdbank(): STARTING_URL = "https://www.brd.ro/instrumente-utile/curs-valutar-si-dobanzi-de-referinta" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td/text()") contor = 12 while contor < 100: datainput.main(str(z[contor + 1]), str(z[contor]), str(z[contor + 5]), str(z[contor + 6]), "BRD", data_de_azi) if contor >= 93: break contor = contor + 9
def librabank(): STARTING_URL = "http://www.librabank.ro/Curs_valutar/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath('//table[@class="curs_tabel_1"]/tr[position()>1 and position()<14]/td/span/text()') contor = 0 while contor < 33: numar, nume = str(z[contor]).split() datainput.main(nume, nume, str(z[contor + 1]), str(z[contor + 2]), "LibraBank", data_de_azi) # print nume, nume,z[contor+1],z[contor+2],data_de_azi,'LibraBank' contor = contor + 3
def bancaromaneasca(): STARTING_URL = "https://www.banca-romaneasca.ro/instrumente-utile/curs-valutar/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td/text()") contor = 0 while contor < len(z): datainput.main( str(z[contor]), str(z[contor]), str(z[contor + 5]), str(z[contor + 6]), "BancaRomaneasca", data_de_azi ) # print z[contor], z[contor + 5], z[contor + 6] contor = contor + 7
def garantibank(): STARTING_URL = "https://ebank.garantibank.ro/isube/yatirimislemleri/doviz/dovizkur" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td/text()") contor = 6 while contor < len(z): datainput.main( str(z[contor]), str(z[contor]), str(z[contor + 2]), str(z[contor + 5]), "GarantiBank", data_de_azi ) # print z[contor], z[contor + 2], z[contor + 5] contor = contor + 7
def piraeus(): STARTING_URL = "http://www.piraeusbank.ro/Banca/Unelte/curs_ghiseu.html" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td/span/text()") contor = 10 while contor < 25: valoare_1 = re.sub(r"[^0-9-,-.]+", "", str(z[contor + 1])) valoare_2 = re.sub(r"[^0-9-,-.]+", "", str(z[contor + 2])) valoare = re.sub(r"[^A-Za-z]+", " ", str(z[contor])) valoare = valoare.strip() datainput.main(valoare, valoare, valoare_1, valoare_2, "PiraeusBank", data_de_azi) # print valoare, valoare_1, valoare_2 contor = contor + 3
def bancatransilvania(): STARTING_URL = "https://www.bancatransilvania.ro/curs-valutar-spot/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td//text()") contor = 6 while contor < 95: datainput.main( str(z[contor]), str(z[contor + 1]).strip(), str(z[contor + 3]), str(z[contor + 4]), "BancaTransilvania", data_de_azi, ) contor = contor + 7 if contor >= 90: break
def otpbank(): STARTING_URL = "https://www.otpbank.ro/curs-valutar" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//tr/td[position()<5]/text()") contor = 0 while contor < len(z): pres = str(z[contor]) nume = str(z[contor + 1]) val_c = str(z[contor + 2]) val_v = str(z[contor + 3]) datainput.main(pres, nume, val_c, val_v, "OTP", data_de_azi) # pdb.set_trace() # print z[contor],z[contor+1],z[contor+2],z[contor+3],data_de_azi,'OTP' contor = contor + 4
def raiffeisen(): STARTING_URL = "https://www.raiffeisen.ro/persoane-fizice/curs-valutar/" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) z = tree.xpath("//table/tr/td/text()") contor = 4 import pdb pdb.set_trace() while contor < 122: if int(float(z[contor + 3])) > 0 or int(float(z[contor + 4])) > 0: datainput.main( str(z[contor + 1]), str(z[contor]), str(z[contor + 3]), str(z[contor + 4]), "Raiffeisen", data_de_azi ) # print z[contor+1], z[contor], z[contor + 3], z[contor + 4], 'Raiffeisen', data_de_azi contor = contor + 7
def alphabank(): STARTING_URL = "https://www.alphabank.ro/ro/rate/rate_si_dobanzi.php" page = requests.get(STARTING_URL) tree = html.fromstring(page.text) # print (etree.tostring(tree,encoding = unicode, pretty_print = True)) e = tree.xpath('//tr[@height="18"]/td[@class="stilTd1"]/text()') z = tree.xpath('//tr[@height="18"]/td[@class="stilTd2"]/text()') contor = 0 while contor < len(e): valoare = re.sub(r"[^A-Za-z]+", " ", str(e[contor])) valoare_1 = re.sub(r"[^A-Za-z]+", " ", str(z[contor])) datainput.main( valoare[(len(valoare) - 4) : (len(valoare) - 1)], valoare[0 : (len(valoare) - 4)], str(e[contor + 2]), str(e[contor + 3]), "AlphaBank", data_de_azi, ) datainput.main( valoare_1[(len(valoare_1) - 4) : (len(valoare_1) - 1)], valoare_1[0 : (len(valoare_1) - 4)], str(z[contor + 2]), str(z[contor + 3]), "AlphaBank", data_de_azi, ) # print valoare[(len(valoare) - 4):(len(valoare) - 1)], valoare[0:(len( # valoare) - 4)], str(e[contor + 2]), str(e[contor + 3]), 'AlphaBank', data_de_azi # print valoare_1[(len(valoare_1) - 4):(len(valoare_1) - 1)], valoare_1[0:( # len(valoare_1) - 4)], str(z[contor + 2]), str(z[contor + 3]), 'AlphaBank', data_de_azi contor = contor + 6