Last active
October 2, 2017 10:36
-
-
Save SilvaEmerson/45e9200e16defb5533bfd77b2b1be9b4 to your computer and use it in GitHub Desktop.
Script de consulta à situação de pagamento com relação à um prazo dado e o CPF do requisitante
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import requests | |
except: | |
print("Por favor instale o módulo Requests") | |
try: | |
from bs4 import BeautifulSoup | |
except: | |
print("Por favor instale o módulo BeutifulSoup:\nhttps://www.crummy.com/software/BeautifulSoup/bs4/download/") | |
print('Prazo deve ser entre 30 dias') | |
day_beg = int(input('Dia inicial: ')) | |
month_beg = int(input('Mês início: ')) | |
day_end = int(input('Dia final: ')) | |
month_end = int(input('Mês final: ')) | |
cpf = int(input("Seu cpf: ")) | |
print("Fazendo requisição...\n\n") | |
response = requests.get('http://www.portaltransparencia.gov.br/despesasdiarias/resultado?consulta=rapida&periodoInicio={}%2F{}%2F2017&periodoFim={}%2F{}%2F2017&fase=PAG&codigoOS=TOD&codigoFavorecido={}'.format( | |
str(day_beg).zfill(2), | |
str(month_beg).zfill(2), | |
str(day_end).zfill(2), | |
str(month_end).zfill(2), | |
str(cpf).zfill(2) | |
)) | |
soup = BeautifulSoup(response.content, 'html.parser') | |
result = soup.select("tr.impar .campo") | |
print("Nenhum pagamento") if len(result) == 0 else print("Data do pagamento:", | |
list(map(lambda x: x.get_text(), | |
result))[0][0:10]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment