Tuesday, July 12, 2011

Simple Script to Download epaper from Times of India

#Written for a friend in need
#Script to download epaper from indiatimes.com
#As always /// Its free to use...
#Get user to select edition
edition_choice=([0]=TOIM [1]=CAP [2]=TOIB [3]=TOIKM [4]=TOICH [5]=TOIPU [6]=TOIA [7]=TOIL [8]=TOIJ [9]=TOIH)
echo "Times of India epaper editions are"
echo "-------------------------------------------------"
echo "0. Mumbai"
echo "1. Delhi"
echo "2. Bangalore"
echo "3. Kolkata"
echo "4. Chennai"
echo "5. Pune"
echo "6. Ahmedabad"
echo "7. Lucknow"
echo "8. Jaipur"
echo "9. Hyderabad"
echo "-------------------------------------------------"
while true; do
    read -p "Enter edition you wish to selec[0-9]: " ed
    case $ed in
 echo "Thanks." 
        * ) echo "Please select the correct numeric serial.";;
#Get user to input starting page
read -p "Please enter the starting page you wish to download from?" strt_pg
#Get user to input ending page
read -p "Please enter the ending page you wish to download?" end_pg
while true; do
    read -p "Do you wish download pages $strt_pg to $end_pg? [Y/N]" yn
    case $yn in
        [Yy]* ) 
    for ((  i = $strt_pg ;  i <= end_pg;  i++  ))
      echo "Downloading Page $i";
      I_FILE="http://epaper.timesofindia.com/Repository/${edition_choice[ed]}/`date +%Y`/`date +%m`/`date +%d`/${edition_choice[ed]}_`date +%Y`_`date +%-m`_`date +%d`_$i.pdf"
      wget $I_FILE 
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;

How to get it running

Copy the script to your Linux desktop
 go to command prompt using terminal
 type following commands

cd ~/Desktop
chmod +x test_1.sh

14 Jul 2011 0026 : Script updated to reflect various editions....

No comments:

Post a Comment