Jump to content

Comic Downloader


this-is-me
 Share

Recommended Posts

I got fed up with my comics by email because I would have to pay to get more than just one per day. Therefore, I made a program that just downloads the ones I need, and shows them. I am sure there are more out there, but most of them rely on the dates and so on being the same as the name of the gif or jpeg used for the strip. My script actually looks for what's on the page, and parses it. That way, if something changes, the script will still work.

Here we go:

#include "imgsize.au3"

opt("Trayicondebug", 1)
$cur = 1
$comicscom = "comics/arlonjanis:Arlo and Janis|_
creators/bc:BC|_
creators/heathcliff:HeathCliff|_
comics/bornloser:Born Loser|_
comics/dilbert:Dilbert|_
comics/franknernest:Frank and Ernest|_
comics/marmaduke:Marmaduke|_
comics/roseisrose:Rose Is Rose|_
wash/cheapthrills:Cheap Thrills Quisine|_
comics/drabble:Drabble|_
comics/frazz:Frazz|_
comics/jestsports:Jest Sports|_
comics/kitncarlyle:Kit and Carlyle|_
comics/offthemark:Off the Mark"
$rbmacom = "Baby_Blues|_
Barney_Google|_
Beetle_Bailey|_
Better_Half|_
Blondie|_
Family_Circus"
$ucomics="foxtrot:FoxTrot|_
garfield:Garfield|_
cathy:Cathy|_
ziggy:Ziggy"
;forbetterorforworse|_

$outdir = @ScriptDir & "\" & @MON & @MDAY & @YEAR
DirRemove($outdir, 1)
DirCreate($outdir)

FileInstall("wget.exe", @TempDir & "\wget.exe")

$comspl = StringSplit($comicscom, "|")
for $a = 1 to $comspl[0]
   $conv = StringSplit($comspl[$a], ":")
   $loc = $conv[1]
   $nm = $conv[2]
   $tmpfile = @TempDir & "comic.tmp"
    ToolTip('Downloading "http://www.comics.com/' & $loc & '"')
   InetGet("http://www.comics.com/" & $loc, $tmpfile, 1)
   if Not @error Then
      $spl = StringSplit(FileRead($tmpfile, FileGetSize($tmpfile)), @LF)
      for $i = 1 to $spl[0]
         if StringInStr($spl[$i], "ALT=""Today's") Then
            $pos = StringInStr($spl[$i],'<img src="',0 , -1)
            $str = StringRight($spl[$i], StringLen($spl[$i]) - $pos - 9)
            $pos2 = StringInStr($str, '"')
            $str2 = StringLeft($str, $pos2 - 1)
            $url = $str2
            if StringLeft($str2, 1) = "/" Then $url = "http://www.comics.com" & $str2
            $outfile = $outdir & "\" & $nm & ".gif"
            if StringInStr($url, ".jpg") Then $outfile = $outdir & "\" & $nm & ".jpg"
            $cur = $cur + 1
                ToolTip('Downloading "' & $url & '"')
            URLDownloadToFile($url, $outfile)
         EndIf
      Next
   EndIf
Next
$comspl = StringSplit($rbmacom, "|")
for $a = 1 to $comspl[0]
    ToolTip('Downloading "' & $comspl[$a] & '"')
   RunWait(@TempDir & '\wget.exe --referer=http://www.kingfeatures.com/ http://est.rbma.com/content/' & $comspl[$a] & '?date=' & @YEAR & @MON & @MDAY & ' -O "' & $outdir & '\' & StringReplace($comspl[$a], "_", " ") & '.gif"', "", @SW_HIDE)
    $cur = $cur + 1
  ;URLDownloadToFile("http://est.rbma.com/content/" & $loc & "?date=" & @YEAR & @MON & @MDAY, $outdir & "\" & $cur & ".gif")
Next

$comspl = StringSplit($ucomics, "|")
for $a = 1 to $comspl[0]
   $conv = StringSplit($comspl[$a], ":")
   $loc = $conv[1]
   $nm = $conv[2]
   $tmpfile = @TempDir & "comic.tmp"
    ToolTip('Downloading "http://www.ucomics.com/' & $loc & '"')
   InetGet("http://www.ucomics.com/" & $loc, $tmpfile, 1)
   if Not @error Then
      $spl = StringSplit(FileRead($tmpfile, FileGetSize($tmpfile)), @LF)
      for $i = 1 to $spl[0]
            $pos = StringInStr($spl[$i], '<img src="http://images.ucomics.com/comics/')
         if $pos <> 0 Then
            $str = StringTrimLeft($spl[$i], $pos + 9)
            $pos2 = StringInStr($str, '"')
            $url = StringLeft($str, $pos2 - 1)
            $outfile = $outdir & "\" & $nm & ".gif"
            if StringInStr($url, ".jpg") Then $outfile = $outdir & "\" & $nm & ".jpg"
            $cur = $cur + 1
                ToolTip('Downloading "' & $url & '"')
            URLDownloadToFile($url, $outfile)
                #ce
         EndIf
      Next
   EndIf
Next

FileDelete(@TempDir & "\wget.exe")

$hdr = ""
$mid = ""

$search = FileFindFirstFile($outdir & "\*.*")  

If $search <> -1 Then
   While 1
      $file = FileFindNextFile($search)
      if $file = "." or $file = ".." Then ContinueLoop
      If @error Then ExitLoop
      $arr = _GetImageSize($outdir & "\" & $file)
      if not @error Then
         if $arr[0] < 400 Then
            $hdr = $hdr & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'
         Else
            $mid = $mid & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'
         EndIf
      Else
         $mid = $mid & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'
      EndIf
   Wend
   FileClose($search)
EndIf

FileWrite($outdir & "\view.htm", $hdr & $mid)

shellexecute($outdir & "\view.htm", "", 0)

func shellexecute($file, $verb, $wait)
    local $oldopt = opt("expandenvstrings", 0)
    $ext = StringTrimLeft($file, StringInStr($file, ".", 0, -1))
    $fltp = RegRead("HKEY_CLASSES_ROOT\." & $ext, "")
    if @error Then $fltp = $ext & "file"
    $defverb = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell", "")
    if $defverb = "" Then $defverb = "Open"
    if $verb = "" Then
        $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $defverb & "\command", "")
    Else
        $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $verb & "\command", "")
    EndIf
    if @error Then
        $cmd = RegEnumKey("HKEY_CLASSES_ROOT\" & $fltp & "\shell", 1)
        if @error Then Return 2
    EndIf
    $cmd = StringReplace($cmd, "%l", FileGetLongName($file))
    $cmd = StringReplace($cmd, "%1", $file)
    $cmd = StringReplace($cmd, "%*", "")
    for $i = 2 to 9
        $cmd = StringReplace($cmd, "%" & $i, "")
    Next
;Why do I have to do this instead of expandenvstrings?
    $env = StringInStr($cmd, "%", 0, 1)
    if not @error Then
        for $i = 1 to 5 Step 2
            if not StringInStr($cmd, "%", 0, $i) Then ExitLoop
            $envx = StringMid($cmd, StringInStr($cmd, "%", 0, $i) + 1, StringInStr($cmd, "%", 0, $i + 1) - 2)
            $cmd = StringReplace($cmd, "%" & $envx & "%", EnvGet($envx))
        Next
    EndIf
    if $wait Then
        RunWait($cmd)
    Else
        Run($cmd)
    EndIf
    opt("expandenvstrings", $oldopt)
endfunc

Have over 20 comics in your face in the morning. :ph34r:

This script is also customizable to download any comics from ucomics.com, comics.com, or kingfeatures.com Just change the variables accordingly.

You will need to also download wget.exe from http://unxutils.sourceforge.net/ or google it if you don't want to get the whole package. The imgsize.au3 udf from larry is here: http://www.autoitscript.com/forum/index.ph...opic=4159&st=15

EDIT: Updated to compile the target page with a better look

Edited by this-is-me
Who else would I be?
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

You need to put the imgsize.au3 and wget.exe both in the same folder as my script. Then just run it.

<{POST_SNAPBACK}>

Okay, thanks for that. I didn't state my question very well. I have the script working, and have added many cartoons. The script is very well done and easy to adapt.

On the website ucomics.com, they have some comics where they only put sample comics on the corresponding page. As opposed to having today's comic on that page. Bloom County and the Wizard of Id are a few examples.

I guess my question is if anyone had found how to get those comics. Sorry about the misunderstanding.

As I said, the script is great. Good piece of coding.

Take care,

-Dw

---

The secret of success is sincerity. Once you can fake that, you have it made.

Link to comment
Share on other sites

Well I looked at the info, but it really does not look like there is a place where (without a password) these comics are downloadable. Sorry.

<{POST_SNAPBACK}>

Okay, thanks for trying. The good thing is that you used three different comic providers. So a lot of times I can get the password protected Ucomics.com at Comics.com or KingFeatures.com.

Take care,

-Dw

---

You have the right to remain silent. Anything you say will be misquoted, then used against you.

Link to comment
Share on other sites

  • 3 years later...

hmm not working :)

---------------------------

AutoIt Error

---------------------------

Line 109 (File "...Desktop\test\comics.au3"):

func shellexecute($file, $verb, $wait)

Error: Badly formatted "Func" statement.

---------------------------

OK

---------------------------

Link to comment
Share on other sites

CODE
#include "imgsize.au3"

opt("Trayicondebug", 1)

$cur = 1

$comicscom = "comics/arlonjanis:Arlo and Janis|creators/bc:BC|creators/heathcliff:HeathCliff|comics/bornloser:Born Loser|comics/dilbert:Dilbert|comics/franknernest:Frank and Ernest|comics/marmaduke:Marmaduke|comics/roseisrose:Rose Is Rose|wash/cheapthrills:Cheap Thrills Quisine|comics/drabble:Drabble|comics/frazz:Frazz|comics/jestsports:Jest Sports|comics/kitncarlyle:Kit and Carlyle|comics/offthemark:Off the Mark"

$rbmacom = "Baby_Blues|Barney_Google|Beetle_Bailey|Better_Half|Blondie|Family_Circus"

$ucomics="foxtrot:FoxTrot|garfield:Garfield|cathy:Cathy|ziggy:Ziggy"

;forbetterorforworse|_

$outdir = @ScriptDir & "\" & @MON & @MDAY & @YEAR

DirRemove($outdir, 1)

DirCreate($outdir)

FileInstall("wget.exe", @TempDir & "\wget.exe")

$comspl = StringSplit($comicscom, "|")

for $a = 1 to $comspl[0]

$conv = StringSplit($comspl[$a], ":")

$loc = $conv[1]

$nm = $conv[2]

$tmpfile = @TempDir & "comic.tmp"

ToolTip('Downloading "http://www.comics.com/' & $loc & '"')

InetGet("http://www.comics.com/" & $loc, $tmpfile, 1)

if Not @error Then

$spl = StringSplit(FileRead($tmpfile, FileGetSize($tmpfile)), @LF)

for $i = 1 to $spl[0]

if StringInStr($spl[$i], "ALT=""Today's") Then

$pos = StringInStr($spl[$i],'<img src="',0 , -1)

$str = StringRight($spl[$i], StringLen($spl[$i]) - $pos - 9)

$pos2 = StringInStr($str, '"')

$str2 = StringLeft($str, $pos2 - 1)

$url = $str2

if StringLeft($str2, 1) = "/" Then $url = "http://www.comics.com" & $str2

$outfile = $outdir & "\" & $nm & ".gif"

if StringInStr($url, ".jpg") Then $outfile = $outdir & "\" & $nm & ".jpg"

$cur = $cur + 1

ToolTip('Downloading "' & $url & '"')

URLDownloadToFile($url, $outfile)

EndIf

Next

EndIf

Next

$comspl = StringSplit($rbmacom, "|")

for $a = 1 to $comspl[0]

ToolTip('Downloading "' & $comspl[$a] & '"')

RunWait(@TempDir & '\wget.exe --referer=http://www.kingfeatures.com/ http://est.rbma.com/content/' & $comspl[$a] & '?date=' & @YEAR & @MON & @MDAY & ' -O "' & $outdir & '\' & StringReplace($comspl[$a], "_", " ") & '.gif"', "", @SW_HIDE)

$cur = $cur + 1

;URLDownloadToFile("http://est.rbma.com/content/" & $loc & "?date=" & @YEAR & @MON & @MDAY, $outdir & "\" & $cur & ".gif")

Next

$comspl = StringSplit($ucomics, "|")

for $a = 1 to $comspl[0]

$conv = StringSplit($comspl[$a], ":")

$loc = $conv[1]

$nm = $conv[2]

$tmpfile = @TempDir & "comic.tmp"

ToolTip('Downloading "http://www.ucomics.com/' & $loc & '"')

InetGet("http://www.ucomics.com/" & $loc, $tmpfile, 1)

if Not @error Then

$spl = StringSplit(FileRead($tmpfile, FileGetSize($tmpfile)), @LF)

for $i = 1 to $spl[0]

$pos = StringInStr($spl[$i], '<img src="http://images.ucomics.com/comics/')

if $pos <> 0 Then

$str = StringTrimLeft($spl[$i], $pos + 9)

$pos2 = StringInStr($str, '"')

$url = StringLeft($str, $pos2 - 1)

$outfile = $outdir & "\" & $nm & ".gif"

if StringInStr($url, ".jpg") Then $outfile = $outdir & "\" & $nm & ".jpg"

$cur = $cur + 1

ToolTip('Downloading "' & $url & '"')

URLDownloadToFile($url, $outfile)

#ce

EndIf

Next

EndIf

Next

FileDelete(@TempDir & "\wget.exe")

$hdr = ""

$mid = ""

$search = FileFindFirstFile($outdir & "\*.*")

If $search <> -1 Then

While 1

$file = FileFindNextFile($search)

if $file = "." or $file = ".." Then ContinueLoop

If @error Then ExitLoop

$arr = _ImageGetSize($outdir & "\" & $file)

if not @error Then

if $arr[0] < 400 Then

$hdr = $hdr & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'

Else

$mid = $mid & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'

EndIf

Else

$mid = $mid & '<br><br>' & StringTrimRight($file, 4) & '<br><img src="' & $outdir & "\" & $file & '">'

EndIf

Wend

FileClose($search)

EndIf

FileWrite($outdir & "\view.htm", $hdr & $mid)

bshellexecute($outdir & "\view.htm", "", 0)

func bshellexecute($file, $verb, $wait)

local $oldopt = opt("expandenvstrings", 0)

$ext = StringTrimLeft($file, StringInStr($file, ".", 0, -1))

$fltp = RegRead("HKEY_CLASSES_ROOT\." & $ext, "")

if @error Then $fltp = $ext & "file"

$defverb = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell", "")

if $defverb = "" Then $defverb = "Open"

if $verb = "" Then

$cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $defverb & "\command", "")

Else

$cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $verb & "\command", "")

EndIf

if @error Then

$cmd = RegEnumKey("HKEY_CLASSES_ROOT\" & $fltp & "\shell", 1)

if @error Then Return 2

EndIf

$cmd = StringReplace($cmd, "%l", FileGetLongName($file))

$cmd = StringReplace($cmd, "%1", $file)

$cmd = StringReplace($cmd, "%*", "")

for $i = 2 to 9

$cmd = StringReplace($cmd, "%" & $i, "")

Next

;Why do I have to do this instead of expandenvstrings?

$env = StringInStr($cmd, "%", 0, 1)

if not @error Then

for $i = 1 to 5 Step 2

if not StringInStr($cmd, "%", 0, $i) Then ExitLoop

$envx = StringMid($cmd, StringInStr($cmd, "%", 0, $i) + 1, StringInStr($cmd, "%", 0, $i + 1) - 2)

$cmd = StringReplace($cmd, "%" & $envx & "%", EnvGet($envx))

Next

EndIf

if $wait Then

RunWait($cmd)

Else

Run($cmd)

EndIf

opt("expandenvstrings", $oldopt)

endfunc

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...