Unix lynx in shell script to input data into website and grep result

1.1k views Asked by At

Pretty new to unix shell scripting here, and I have some other examples to look at but still trying from almost scratch. I'm trying to track deliveries for our company, and I have a script I want to run that will input the tracking number into the website, and then grep the result to a file (delivered/not delivered). I can use the lynx command to get to the website at the command line and see the results, but in the script it just returns the webpage, and doesn't enter the tracking number.

Here's the code I have tried that works up to this point:

#$1 = 1034548607
FNAME=`date +%y%m%d%H%M%S`

echo requiredmcpartno=$1 | lynx -accept_all_cookies -nolist -dump -post_data http://apps.yrcregional.com/shipmentStatus/track.do 2>&1 | tee $FNAME >/home/jschroff/log.lg

DLV=`grep "PRO" $FNAME | cut --delimiter=: --fields=2 | awk '{print $DLV}'`

echo $1 $DLV  > log.txt
rm $FNAME

I'm trying to get the results for the tracking number(PRO number as they call it) 1034548607.

1

There are 1 answers

2
Gilles Quénot On BEST ANSWER

Try doing this with :

trackNumber=1234
curl -A Mozilla/5.0 -b cookies -c cookies -kLd "proNumber=$trackNumber" http://apps.yrcregional.com/shipmentStatus/track.do

But verify the TOS to know if you are authorized to scrape this web site.

If you want to parse the output, give us a sample HTML output.