Last active
November 23, 2018 15:02
-
-
Save Yrds/0d3d78ff6a6a04a028233826597af19b to your computer and use it in GitHub Desktop.
Script simples que retorna o estado atual de um objeto dos correios. Uso: "./rastreio.sh CODIGO"
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
#!/bin/bash | |
cd /tmp/ | |
codigo=$1 | |
if [ -z $1 ]; then | |
··echo -e "ERRO: É preciso inserir um código de rastreio\nExemplo: rastreio.sh PR112318237BR" | |
··exit | |
fi | |
curl -s 'https://www2.correios.com.br/sistemas/rastreamento/ctrl/ctrlRastreamento.cfm?' \ | |
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0' \ | |
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ | |
-H 'Accept-Language: en-US,en;q=0.5' \ | |
--compressed -H 'Referer: https://www2.correios.com.br/sistemas/rastreamento/' \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Upgrade-Insecure-Requests: 1' \ | |
--data 'acao=track&objetos='$codigo'&btnPesq=Buscar' \ | |
--cookie-jar cookie_file | |
curl -s 'https://www2.correios.com.br/sistemas/rastreamento/resultado.cfm' \ | |
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0' \ | |
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ | |
-H 'Accept-Language: en-US,en;q=0.5' \ | |
--compressed -H 'Referer: https://www2.correios.com.br/sistemas/rastreamento/' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Upgrade-Insecure-Requests: 1' \ | |
--cookie cookie_file -o dump.html | |
cat dump.html | tr "\r" "\n" > dump2.html | |
cat dump2.html | grep "Objeto encami" -A1 -m1 | tail -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment