Skip to content

Instantly share code, notes, and snippets.

@jjesusfilho
Created August 27, 2023 13:53
Show Gist options
  • Save jjesusfilho/01ade572e8e2ad53bd17b02c054bb7bd to your computer and use it in GitHub Desktop.
Save jjesusfilho/01ade572e8e2ad53bd17b02c054bb7bd to your computer and use it in GitHub Desktop.
TPUs com python requests e zeep.
import requests
from lxml import etree
from datetime import datetime
def tpu_get_data_ultima_versao():
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sgt="https://www.cnj.jus.br/sgt/sgt_ws.php">
<soapenv:Header/>
<soapenv:Body>
<sgt:getDataUltimaVersao/>
</soapenv:Body>
</soapenv:Envelope>"""
url1 = "https://www.cnj.jus.br/sgt/sgt_ws.php"
resposta = requests.post(url1, data= body)
conteudo = etree.fromstring(resposta.content) \
.find('.//return') \
.text
data = datetime.strptime(conteudo, '%d/%m/%Y').date()
return data
from zeep import Client
from datetime import datetime
def tpu_get_data_ultima_versao():
client = Client(wsdl = "https://www.cnj.jus.br/sgt/sgt_ws.php?wsdl")
conteudo = client.service.getDataUltimaVersao()
data = datetime.strptime(conteudo, '%d/%m/%Y').date()
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment