I have this code, that readme all urls from a column, i have a problem with the last row, that row upload a column with an round(int(soup.find('MntTotal').text)*0.1) , that means the total amount of the invoice by 10%, so when i run the code, the result just give me a 0, instead of 35037.
This is the url problem: http://windte1910.acepta.com/v01/9D2D349D4BE95B5F92110528164B7FC179807C14
for idx,row in df.iterrows():
url = row['e.URL'].replace('/v01/', '/depot/')
x = urlopen(url)
new = x.read()
soup = BeautifulSoup(new, "lxml-xml")
found = re.search(r"(?i)cl[a-zA-Z]{3}\d{5}", str(soup))
appointment = found.group(0) if found else ''
rut = soup.find('RUTEmisor').text
tipo_dte = soup.find('TipoDTE').text
monto_neto = getattr(soup.find('MntNeto'), 'text', 0)
stephens = ''.join(re.findall(r"HONORARIO", str(soup)))
stephens2 = ''.join(re.findall(r"DESEMBOLSO", str(soup)))
agental_launch = ''.join(re.findall(r"LAUNCH", str(soup)))
anchoring = ''.join(re.findall(r"anchoring", str(soup)))
berthing = ''.join(re.findall(r"berthing", str(soup)))
tugboat = ''.join(re.findall(r"(?i)tugboat", str(soup)))
if rut == '79524890-0' and stephens != "":
df.at[idx,'REBATE'] = int(100)
elif rut == '79524890-0' and stephens2 != "":
df.at[idx,'REBATE'] = int(int(soup.find('MntTotal').text)*0.2)
elif rut == '80010900-0' and agental_launch != "" and 'TAL' or 'IQQ' or 'ANF' or 'MJS' or 'QTV' or 'SVE' or 'PMC' or 'CHB' in appointment:
df.at[idx,'REBATE'] = round(int(monto_neto)*0.35)
elif rut == '80010900-0' and agental_launch != "" and 'ZUD' in appointment:
df.at[idx,'REBATE'] = int(350)
elif rut == '78986820-4' and anchoring != "":
df.at[idx,'REBATE'] = round(int(soup.find('MntNeto').text)*0.15)
elif rut == '78986820-4' and berthing != "":
df.at[idx,'REBATE'] = round(int(soup.find('MntNeto').text)*0.35)
elif rut == '76542910-2':
df.at[idx,'REBATE'] = round(int(soup.find('MntTotal').text)*0.1)
The other conditions works perfect, so this is the result:

Aucun commentaire:
Enregistrer un commentaire