I'm sorry for the layman's question but I've researched everywhere without finding a way out. I have the code below and I'm 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'm starting for another idea). This code is working fine until you save the files locally but from 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()
Sorry if the question is not clear but is, as I said, I am a total layman in any programming language (I started a month ago out of curiosity and fascination). Hugs,