Created
January 27, 2022 21:04
-
-
Save renatoagomes/9e8b367f6f37a9df1a5a6e6e1758207d to your computer and use it in GitHub Desktop.
CLI Obter código de barras de boletos da CPFL
This file contains 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
#! /usr/bin/sh | |
timestamp=$(date +%d-%m-%Y) | |
codigo=$1; | |
documento=$2 | |
curl 'https://servicosonline.cpfl.com.br/agencia-webapi/api/via-pagamento/validar-situacao' \ | |
-H 'authority: servicosonline.cpfl.com.br' \ | |
-H 'pragma: no-cache' \ | |
-H 'cache-control: no-cache' \ | |
-H 'accept: application/json, text/plain, */*' \ | |
-H 'x-dtpc: 1$405007446_72h7vAVEHASLWKRFAUQSOKKAREKHPHMLKMFRO-0e0' \ | |
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36' \ | |
-H 'content-type: application/json;charset=UTF-8' \ | |
-H 'sec-gpc: 1' \ | |
-H 'origin: https://servicosonline.cpfl.com.br' \ | |
-H 'sec-fetch-site: same-origin' \ | |
-H 'sec-fetch-mode: cors' \ | |
-H 'sec-fetch-dest: empty' \ | |
-H 'referer: https://servicosonline.cpfl.com.br/agencia-webapp/' \ | |
-H 'accept-language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7' \ | |
--data-raw '{"Instalacao":"'${codigo}'","Documento":"'${documento}'","nrContaContrato":null}' \ | |
--compressed > ~/.CPFL_${timestamp}.json | |
codigoBarras=$(cat ~/.CPFL_${timestamp}.json | jq '.ContasAberto[0].CodigoBarras') | |
vencimento=$(cat ~/.CPFL_${timestamp}.json | jq '.ContasAberto[0].Vencimento') | |
valor=$(cat ~/.CPFL_${timestamp}.json | jq '.ContasAberto[0].Valor') | |
echo "Consulta em ${timestamp}" | |
echo "Vencimento ${vencimento}" | |
echo "Valor ${valor}" | |
echo "CodigoBarras ${codigoBarras}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment