We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Exemplo de como consultar nota, NF-e ou NFC-e.
from pynfe.processamento.comunicacao import ComunicacaoSefaz certificado = "/home/user/certificado.pfx" senha = 'senha' uf = 'pr' homologacao = True chave_acesso = '99999999999999999999999999999999999999999999' con = ComunicacaoSefaz(uf, certificado, senha, homologacao) envio = con.consulta_nota('nfe', chave_acesso) # nfe ou nfce print (envio.text.encode('utf-8')) # SEFAZ SP utilizar envio.content
Retirar apenas o conteúdo da tag (para montar o ) após a consulta.
from lxml import etree from pynfe.utils.flags import NAMESPACE_NFE ns = {'ns':NAMESPACE_NFE} prot = etree.fromstring(envio.text.encode('utf-8')) # SEFAZ SP utilizar envio.content status = prot[0][0].xpath('ns:retConsSitNFe/ns:cStat', namespaces=ns)[0].text if status == '100': prot_nfe = prot[0][0].xpath('ns:retConsSitNFe/ns:protNFe', namespaces=ns)[0] xml = etree.tostring(prot_nfe, encoding='unicode') print(xml)
Voltar