Tuesday, July 19, 2011

Simple Script to Download epaper from Mid-Day


#!/bin/bash
#ishan dot karve at gmail dot com
#Script to download epaper from mid-day.com
#As always /// Its free to use...
#Get user to select edition
edition_choice=([0]=mumbai [1]=delhi [2]=bangalore [3]=pune)
edition_abbr=([0]=md-mn [1]=md-dn [2]=md-bn [3]=md-pn)
echo "Mid-Day epaper editions are"
echo "-------------------------------------------------"
echo "0. Mumbai"
echo "1. Delhi"
echo "2. Bangalore"
echo "3. Pune"
echo "-------------------------------------------------"
while true; do
    read -p "Enter edition you wish to selec[0-9]: " ed
    case $ed in
       [0123]) 
 echo "Thanks." 
 break;;
        * ) echo "Please select the correct numeric serial.";;
    esac
done
#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++  ))
    do
      echo "Downloading Page $i"

      I_FILE="http://epaper2.mid-day.com/DRIVE/${edition_choice[ed]}/`date +%d``date +%m``date +%Y`/epaperpdf/19072011-${edition_abbr[ed]}-$i.pdf"
      wget $I_FILE 
    done
     break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done







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 milk_day.sh
./milk_day.sh

No comments:

Post a Comment