Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/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:\/\/plagiaris +t.com\/poetry\/poets\/" . $poet . "\/\'"); open(FILE, $name . "_poet.html"); my $line; $flag = 0; foreach $line (<FILE>) { if ($line =~ m/<li><a href=\"http\:\/\/plagiarist\.com\/poetry +\/(\d+)\/\">/) { $flag = 1; print " Getting poem number $1.\n"; unlink("temp.html"); system("wget -q -O\'" . $name . "_temp.html\' \'http://pla +giarist.com/poetry/" . $1 . "/\'"); open(POEM, $name . "_temp.html"); { local $/ = undef; my $poem = <POEM>; my ($match) = $poem =~ m/<div id=\"poem\">(.*?)<\/div> +/ms; my ($title) = $match =~ m/<title>(.*?)<\/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");

In reply to auden.pl: a poetry scraper by eweaverp

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found