0
Forgive me for asking the layman, but I’ve searched everywhere without finding a way out. I have the code below and I am trying to send the files directly to FTP (initially I wanted to do this without having to save locally, but due to the difficulty in doing I am leaving for another idea). This code is working perfectly until you save the files locally but from the ftp.storlines
gives the following error: "Typeerror: a bytes-like Object is required, not 'str'". Can anyone help?
from dominate import document
from dominate.tags import *
from ftplib import FTP
import getpass
psw = getpass.getpass('Digite sua senha: ')
ftp = FTP('sasasa.com.as')
ftp.login('usr', psw)
ftp.cwd('sasasa.com.as/cdc/sds')
border = "1"
for index, row in UltimaCotacao.iterrows():
h = html()
with h.add(body()):
h1('Algo')
with table().add(tbody()):
l = tr()
l += td('CNPJ: ', row['CNPJ_'])
l += td('Valor da cota: ', row['VL_QUOTA'])
l += td('Data: ', row['DT_COMPTC'])
g = format_filename(row['CNPJ_'])+'.html'
with open(g, 'w') as f:
f.write(h.render())
locpath = 'C:/Users/proj/'
ftp.storlines('STOR ' + g, open(locpath+g, 'r'))
ftp.quit()
I’m sorry if the question is unclear, but as I said, I’m a total layman in any programming language (I started a month ago out of curiosity and fascination). Hugs,