Script for Estafeta package tracking using a tracking code

Are you looking to track your package sent via estafeta in mexico? This shell script will help you do that without using your web browser. Example:

[amado@localhost ~]$ ~/bin/estafeta.sh 99999
Localisando el # de guia: 99999

   04/11/2012 08:37 PM
   Guadalajara Llegada a centro de distribución GDL Guadalajara

   04/11/2012 08:44 PM
   Guadalajara En ruta foránea hacia REX-Reynosa
     __________________________________________________________________

   Versión 3.2

Create the script!

The source code is fairly simple. First, execute a curl request. Then, parse the response. For this we use lynx and sed.

estafeta.sh:

#!/bin/bash

guia="$1"

if [ "$guia" = "" ]; then
	echo "El # de guia no fue proporcionado. "
	exit
fi

echo "Localisando el # de guia: $guia"

curl $FIRECURL_OPTIONS -s -X 'POST'   -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'   -H 'Accept-Encoding: gzip, deflate'   -H 'Accept-Language: en-US,en;q=0.5'   -H 'Connection: keep-alive'   -H 'DNT: 1'   -H 'Host: rastreo3.estafeta.com'   -H 'Referer: http://estafeta.com/'   -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20100101 Firefox/17.0'   --form-string 'method='   --form-string 'forward='   --form-string 'idioma=es'   --form-string 'pickUpId='   --form-string 'dispatch=doRastreoInternet'   --form-string 'tipoGuia=REFERENCE'   --form-string "guias=$guia"   --form-string 'image.x=57'   --form-string 'image.y=23' 'http://rastreo3.estafeta.com/RastreoWebInternet/consultaEnvio.do' | lynx -dump -stdin -nolist -display_charset=utf8 | sed '1,/Historia/d' | sed '1,/Comentarios/d'

#done.

Track your package!

For executing the script. set chmod u+x, and pass the tracking id to the script.

[amado@localhost ~]$ ~/bin/estafeta.sh 99999
Localisando el # de guia: 99999

   04/11/2012 08:37 PM
   Guadalajara Llegada a centro de distribución GDL Guadalajara

   04/11/2012 08:44 PM
   Guadalajara En ruta foránea hacia REX-Reynosa
     __________________________________________________________________

   Versión 3.2

Big thanks to the FireCurl firefox plugin which makes writing curl requests super-easy!

  • Roy Johnson

    I’m trying to get some insight on coding for Estafeta. Not really a coding guy but I am interested in setting up a market in Mexico and the coding for it seems to be over my head. Any advice on how to get this going?