SHARE
TWEET

eduo

a guest Apr 21st, 2009 1,112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. curl --stderr - http://store.xkcd.com/ | grep "option value=\"XKC-"| grep '\-signed' |tr -d '\t' | cut -f2 -d '>' | cut -f1 -d '<' | while read line
  2. do
  3. COMICID=`echo "$line" | cut -f1 -d" " | cut -c2-`
  4. COMICTITLE=`echo "$line" | cut -f2- -d" "`
  5.  
  6. COMICURL="http://xkcd.com/$COMICID/"
  7.  
  8. IMGDATA=`curl --stderr - "$COMICURL" | grep img | grep title | grep "imgs.xkcd.com" | sed -e's/<img src="//g' -e's/" title="/\|/g' -e's/" alt="/\|/g' -e's|" /><br/>||g' -e's|" /></a><br/>||g'`
  9.  
  10. IMGSRC=`echo "$IMGDATA" | cut -f1 -d\|`
  11.  
  12. IMGTYPE=`echo "$IMGSRC" | cut -c1`
  13.  
  14. case "$IMGTYPE" in
  15.  
  16. "h")
  17. IMGBIG="$IMGSRC"
  18.  
  19. ;;
  20.  
  21. \<)
  22.  
  23. IMGBIG=`echo "$IMGSRC" | cut -f2 -d \"`
  24. IMGSRC2="$IMGSRC"
  25. IMGSRC=`echo "$IMGSRC2" | cut -f2 -d \>`
  26.  
  27. ;;
  28.  
  29. esac
  30.  
  31. IMGALT=`echo "$IMGDATA" | cut -f2 -d\|`
  32. IMGTITLE=`echo "$IMGDATA" | cut -f3 -d\|`
  33.  
  34. echo "<div align=\"center\" style=\"border: 1px dotted solid gray;align:center;width:90%\">
  35. <h2>#$COMICID - $IMGTITLE</h2>
  36. <a rel=\"lightbox\" href=\"$IMGBIG\"><img style=\"border: 0px;width:90%\" src=\"$IMGSRC\" title=\"$IMGALT\" alt=\"$IMGTITLE\" /></a><br/>
  37. <span style=\"color:darkgray\">($IMGALT)</span><br/>
  38. <a href=\"$COMICURL\">$IMGTITLE</a><br/>
  39. </div><br/>"
  40.  
  41. done
RAW Paste Data
Top