Jump to content

Comic downloader & HTML generator


ahab
 Share

Recommended Posts

Similar to Marc's script

downloads the current day's comics from

http://www.pvponline.com/

http://www.inktank.com/AT/

http://www.inktank.com/WW/

http://www.penny-arcade.com/index.php3

http://www.creators.com/comics_show.cfm?comicname=bs

then creates two html files, one called index and one named for the current date. So you can make a link to index.html as it will always be there, and then you can go to previous days from there. I plan to run it as a scheduled task twice a day or so and just let it go.

;by ahab, July 2004, 1.01
;1.0
#include <Date.au3>
$YMD = @YEAR & @MON & @MDAY
$WRITEHTML = 0
$INDEX = "index.html"

;PVP get
If FileGetSize("pvp" & $YMD & ".gif") < 5000 Then
   URLDownloadToFile("http://www.pvponline.com/archive/" & @YEAR & "/pvp" & $YMD & ".gif", "pvp" & $YMD & ".gif")
   $WRITEHTML = 1
EndIf

;Ballard Street get
If FileGetSize("bs" & $YMD & ".gif") < 5000 Then
   $MONTH = @MON
   $MDAYOFSUNDAY = 1 - @WDAY + @MDAY
;incase Sunday was last month
   If $MDAYOFSUNDAY < 1 Then
      $MDAYOFSUNDAY = $MDAYOFSUNDAY + _DateDaysInMonth (_DateLastMonthNum(@MON), @YEAR)
      $MONTH = _DateLastMonthNum(@MON)
   ;incase last month was last year
      If $MONTH = 12 Then
         $MDAYOFSUNDAY = $MDAYOFSUNDAY + _DateDaysInMonth (_DateLastMonthNum(@MON), @YEAR - 1)
      EndIf
   EndIf
;Makes sure $MDAYOFSUNDAY is two digits
   $MDAYOFSUNDAY = StringRight($MDAYOFSUNDAY + 100, 2)
   URLDownloadToFile("http://www.creators.com/" & $MONTH & $MDAYOFSUNDAY & "/bs/bs" & @MON & @MDAY & "g.gif", "bs" & $YMD & ".gif")
   $WRITEHTML = 1
EndIf

;Penny Arcade & Angst Technology get
If @WDAY = 2 Or @WDAY = 4 Or @WDAY = 6 Then
   If FileGetSize("pa.jpg" & $YMD & ".gif") < 5000 Then
      URLDownloadToFile("http://www.penny-arcade.com/images/" & @YEAR & "/" & $YMD & "l.jpg", "pa" & $YMD & ".jpg")
      $WRITEHTML = 1
   EndIf
   If FileGetSize("at" & $YMD & ".gif") < 5000 Then
      URLDownloadToFile("http://www.inktank.com/images/AT/cartoons/" & @MON & "-" & @MDAY & "-" & StringRight(@YEAR, 2) & ".gif", "at" & $YMD & ".gif")
      $WRITEHTML = 1
   EndIf
EndIf

;Weakend Warriors get
If @WDAY = 3 Then
   If FileGetSize("ww" & $YMD & ".gif") < 5000 Then
      URLDownloadToFile("http://www.inktank.com/images/WW/cartoons/" & @MON & "-" & @MDAY & "-" & StringRight(@YEAR, 2) & ".gif", "ww" & $YMD & ".gif")
      $WRITEHTML = 1  
   EndIf
EndIf

;check to see if HTML file is there
If Not FileExists($INDEX) Then
   $WRITEHTML = 1
EndIf

;Writes the HTML all at once
If $WRITEHTML = 1 Then
   FileDelete($INDEX)
   FileOpen($INDEX, 1)
   
;opening tags for HTML
   FileWrite($INDEX, "<html><head><title>Comics for " & _DateDayOfWeek(@WDAY, 0) & " " & _DateMonthOfYear(@MON, 0) & " - " & @MDAY & " - " & @YEAR & "</title>" & @CRLF)
   FileWrite($INDEX, "<BODY text=#808080 vLink=#808080 aLink=#808080 link=#808080 bgColor=#000000>" & @CRLF)
   FileWrite($INDEX, "<P align=center><FONT face=Arial size=3><br><br>" & @CRLF)
   
;PVP write
   FileWrite($INDEX, "<A href=""http://www.pvponline.com/""><img src=pvp" & $YMD & ".gif></A><br><br>" & @CRLF)
   
;PA, AT, and WW write
   If @WDAY = 2 Or @WDAY = 4 Or @WDAY = 6 Then
      FileWrite($INDEX, "<A href=""http://www.penny-arcade.com/index.php3""><img src=pa" & $YMD & ".jpg></A><br><br>" & @CRLF)
      FileWrite($INDEX, "<A href=""http://www.inktank.com/AT/""><img src=at" & $YMD & ".gif></A><br><br>" & @CRLF)
   ElseIf @WDAY = 3 Then
      FileWrite($INDEX, "<A href=""http://www.inktank.com/WW/""><img src=ww" & $YMD & ".gif></A><br><br>" & @CRLF)
   EndIf
   
;BS write
   FileWrite($INDEX, "<A href=""http://www.creators.com/comics_show.cfm?comicname=bs""><img src=bs" & $YMD & ".gif></A><br><br>" & @CRLF)
   
;Set prev day's date
   $PDAY = @MDAY - 1
   $PMON = @MON
   $PYEAR = @YEAR
   
;incase previous day was last month
   If $PDAY = 0 Then
      $PMON = @MON - 1
   ;incase previous month was last year
      If $PMON = 0 Then
         $PMON = 12
         $PYEAR = @YEAR - 1
      EndIf
      $PDAY = _DateDaysInMonth ($PMON, $PYEAR)
   ;makes sure $PMON is two digits
      $PMON = StringRight($PMON + 100, 2)
   EndIf
   
;makes sure $PDAY is two digits
   $PDAY = StringRight($PDAY + 100, 2)
   
;Set next day's date
   $NDAY = @MDAY + 1
   $NMON = @MON
   $NYEAR = @YEAR
   
;incase next day is new month
   If $NDAY > _DateDaysInMonth (@MON, @YEAR) Then
      $NDAY = 1
      $NMON = @MON + 1
   ;incase next month happens to be a new year
      If $NMON = 13 Then
         $NMON = 1
         $NYEAR = @YEAR + 1
      EndIf
   ;makes sure $NMON is two digits
      $NMON = StringRight($NMON + 100, 2)
   EndIf
   
;makes sure $PDAY is two digits
   $NDAY = StringRight($NDAY + 100, 2)
   
;write the prev and next links
   FileWrite($INDEX, "<A href=" & $PYEAR & $PMON & $PDAY & ".html>Prev</a> ")
   FileWrite($INDEX, " <A href=" & $NYEAR & $NMON & $NDAY & ".html>Next</a><br>")
   
;closing tags for HTML
   FileWrite($INDEX, "</FONT></P></BODY></HTML>" & @CRLF)
   FileClose($INDEX)
   FileCopy($INDEX, $YMD & ".html")
EndIf
You might also want to see my online brainstorming about figuring out how to figure out the day of sunday. The dates that this program calculates should be good for prettymuch forever.

Feedback is very welcome.

edit: 7/3 5:20 PM CST: the leading zero was not being kept when the date for previous day and next day was calculated, problem fixed using trids suggestion

edit: 7/4 2:00 PM CST: the leading zero was not being kept when calculating the URL for ballard street, used same fix as previous bug

edit 7/5 2:00 AM CST: goofed up in the day that weakend warriors is posted

edit: 11/10 2:00 PM CST: when it was checking the file size of the downloaded comics it wasn't checking the right filename

Edited by ahab
Link to comment
Share on other sites

hmm.... today is friday so it should download 4, 3 .gifs and 1 . jpg, so I re posted my working source.

the prev & next won't work if you haven't ran it for multiple days in a row, they point to tomorrow's and yesterday's comics. So say you go on vacation for a week and let it run daily you can open index.html and hit prev to see yesterdays, and then you want to go forward....

Edited by ahab
Link to comment
Share on other sites

  • 2 years later...

Explosm.net was, according to Wikipedia, founded back in December of 2004, and this was posted some months before that,

in June 2004. That might have something to do with it. Btw, it might be just a tad late to post a reply in a such an old topic, so

I wouldn't hope for the author to follow your request/question.

Edited by Helge
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...