#!/usr/bin/perl use strict; use warnings; my $poet = $ARGV[0]; my $name = $ARGV[1]; if (!$poet || !$name) { print "No poet specified."; exit(); } my $flag = 1; my $count = 1; my %hash; print "Going to retrieve poet number $poet, who you say is $name.\n"; while ($flag) { $flag = 0; if ($count > 1) { print "On page $count.\n"; $poet = $ARGV[0] . "\/$count"; } unlink($name . "_poet.html"); system("wget -q -O\'" . $name . "_poet.html\' \'http:\/\/plagiarist.com\/poetry\/poets\/" . $poet . "\/\'"); open(FILE, $name . "_poet.html"); my $line; $flag = 0; foreach $line () { if ($line =~ m/
  • /) { $flag = 1; print " Getting poem number $1.\n"; unlink("temp.html"); system("wget -q -O\'" . $name . "_temp.html\' \'http://plagiarist.com/poetry/" . $1 . "/\'"); open(POEM, $name . "_temp.html"); { local $/ = undef; my $poem = ; my ($match) = $poem =~ m/
    (.*?)<\/div>/ms; my ($title) = $match =~ m/(.*?)<\/title>/ms; $match =~ s/(?:<.*?>|\<!--|-->|\n\n\n)//mg; $match =~ s/^(?:Submitted by.*| poem| )$//mg; $hash{$title} .= $match; } close(POEM); } } close(FILE); $count ++; } print "Writing it down...\n"; unlink($name . ".txt"); open(OUTPUT, ">$name" . ".txt"); my $title; foreach $title (sort(keys(%hash))) { print " $title\n"; print OUTPUT "_PAGEBREAK_\n\n$hash{$title}\n"; } close(OUTPUT); unlink($name . "_temp.html"); unlink($name . "_poet.html");