LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2008, 07:45 PM   #1
Nimbuz
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Rep: Reputation: 0
Archive Downloader Using Curl Grep Cygwin


Hello,

The following bash script downloads comics from the free 30-day archive. How can the script dowload the comics from membership section using valid username and password? For test purpose only in scripting, the username is user1234 and the password is pass1234. The revised script can login, download, and logout through secure connection. Doable? Thanks in advance.

Code:
#!/bin/bash
# Download comics and put them in the users web directory
# Depends: bsdiff, curl, grep

function download {
  SRC=$1
  FILE=$2
  C_TYPE=`HEAD $SRC|fgrep Content-Type:|cut -d' ' -f2`
  [ ! -e "$FILE" -a "$C_TYPE" != "text/html" ] && \
  wget -q -t inf -A gif,jpg "$SRC" -O "$FILE" && \
  [ x"${FILE##*.}" = x"gif" ] #&& \
#  convert "$FILE" "${FILE%.*}.png" && \
#  rm -f "$FILE"
   echo "$FILE" saved to $PWD ...
}

function changedirectory {

  COMICNAME=$1
  COMICYEAR=$2

  mkdir -p $HOME/public_html/comics/$COMICNAME/$COMICYEAR
  cd $HOME/public_html/comics/$COMICNAME/$COMICYEAR
}

if [ -z "$1" ]
  then
  DATE=`date +"%Y%m%d" -d "-0 day"`
  DATEYR=`date +"%Y" -d "-0 day"`
else
  DATE=$1
fi
mkdir -p $HOME/public_html/comics/
cd $HOME/public_html/comics/

# 9 ChickWeed Lane
changedirectory 9ChickWeedLane $DATEYR
IMG=`curl -s http://www.comics.com/comics/chickweed/archive/chickweed-${DATE}.html \
   | egrep -m 1 -o "/comics/chickweed/archive/images/chickweed[0-9]+.(gif|jpg)"`
download http://www.comics.com$IMG 9ChickWeedLane${DATE}.${IMG##*.}

# Agnes
changedirectory Agnes $DATEYR
IMG=`curl -s http://www.comics.com/creators/agnes/archive/agnes-${DATE}.html \
   | egrep -m 1 -o "/creators/agnes/archive/images/agnes[0-9]+.(gif|jpg)"`
download http://www.comics.com$IMG Agnes${DATE}.${IMG##*.}

# Alley Oop
changedirectory AlleyOop $DATEYR
IMG=`curl -s http://www.comics.com/comics/alleyoop/archive/alleyoop-${DATE}.html \
   | egrep -m 1 -o "/comics/alleyoop/archive/images/alleyoop[0-9]+.(gif|jpg)"`
download http://www.comics.com$IMG AlleyOop${DATE}.${IMG##*.}
 
Old 04-19-2008, 07:53 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Is the site login done using javascript? If so I don't believe it is doable. Most of the text browsers apparently can't interact with javascript.

Of course it was a couple of years ago when I did my check for curl, wget, lynx, links et all. Maybe someone else will have an answer by now but back then I even ran across one site that said not only didn't such a tool exist but they weren't sure one could ever be made.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM
downloader.... duker_d_cooker Linux - General 1 03-10-2004 02:41 AM
Stream Downloader dustinwu Linux - Software 3 02-24-2004 08:41 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM
importing an MS Outlook archive archive.pst alloydog Linux - Software 2 08-29-2003 03:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration