Monks~

Well, I don't know about you all, but I am addicted to a couple of online comics (six at current but more are often added). Back when it was only two or three, I did not mind going from website to website everyday to read them. Sadly now that has become too much effort...

Thus I have sent Perl to the rescue!

Right now, all my script does is use LWP::simple to get each of the chosen webpages, parse through the html for known anchors, and then getstore() the appropriate images. It then generates a simple webpage that has all of my comics one after another. It is written in a fairly generic format, so adding a new website only takes about 10 lines of code... Right now, it is order so that the comics which update more frequently are higher on the page.

I would of course be interested in comments/suggestions
#!c:\perl\perl.exe -w use strict; use LWP::Simple; my @results; my @file; my $i = 0; my @sluggy = split("\n",get("http://www.sluggy.com")); for (@sluggy) { if(/"(http:\/\/pics\.sluggy\.com\/comics\/.*?)"/) { push @results, $1; $1 =~ /.*\.(...)/; push @file, "image_$i.$1"; $i++; } } my @userfriendly = split("\n",get("http://www.userfriendly.org")); for (@userfriendly) { if(/"(http:\/\/www\.userfriendly\.org\/cartoons\/archives\/[\d|\l] +.*?)"/) { push @results, $1; $1 =~ /.*\.(...)/; push @file, "image_$i.$1"; $i++; } } my @sinfest = split("\n",get("http://www.sinfest.net")); for (@sinfest) { if(/"(\/comics\/.*?)"/) { push @results, "http://www.sinfest.net$1"; $1 =~ /.*\.(...)/; push @file, "image_$i.$1"; $i++; } } get("http://www.nuklearpower.com/comic/") =~ /<a href="(.*?)">Newest Comic<\/a>/; my @nuklearpower = split("\n",get("http://www.nuklearpower.com/comic/$ +1")); for (@nuklearpower) { if( /<p align=".*?"><img border=".*?" src="(.*?)" width="720" height="936" +><\/p>/ ) { push @results, "http://www.nuklearpower.com/comic/$1"; $1 =~ /.*\.(...)/; push @file, "image_$i.$1"; $i++; } } my @megatokyo = split("\n",get("http://www.megatokyo.com")); for (@megatokyo) { if(/"(\/strips\/.*?)"/) { push @results, "http://www.megatokyo.com$1"; $1 =~ /.*\.(...)/; push @file, "image_$i.$1"; $i++; } } my @machall = split("\n",get("http://www.machall.com")); for (@machall) { if( /src='(\/index\.php\?do_command=show_strip.*?)'/ ) { push @results, "http://www.machall.com$1"; push @file, "image_$i.jpg"; $i++; } } open PAGE, ">comics.html" || die $!; print PAGE "<html>\n<main>\n<title>Matt's Comic Page</title>"; for(my $i = 0; $i < @results; $i++) { print "$results[$i]\n"; $results[$i] =~ /.*\.(...)/; getstore($results[$i], $file[$i]); print PAGE "<img src=\"$file[$i]\"><br>\n"; } print PAGE "</main>\n</html>"; close PAGE || die $!;

Hope you all enjoy,
Matt
----
Computer science is merely the post-Turing decline of formal systems theory.
-???

In reply to Online Comics by Boots111

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.