2020-02-01 23:30:32 +01:00
|
|
|
#!/usr/bin/perl -w
|
2009-12-09 02:08:12 +01:00
|
|
|
|
2017-03-05 22:33:31 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
# Quick and dirty by :pragma
|
|
|
|
|
|
|
|
use LWP::UserAgent;
|
|
|
|
|
|
|
|
my ($text, $t);
|
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new;
|
|
|
|
$ua->agent("Mozilla/5.0");
|
|
|
|
|
2020-02-15 23:38:32 +01:00
|
|
|
my %post = ('number' => '4', 'collection[]' => '20thcent');
|
2009-12-09 02:08:12 +01:00
|
|
|
|
|
|
|
my $response = $ua->post("http://www.quotationspage.com/random.php3", \%post);
|
|
|
|
|
2020-02-15 23:38:32 +01:00
|
|
|
if (not $response->is_success) {
|
|
|
|
print "Couldn't get quote information.\n";
|
|
|
|
die;
|
2009-12-09 02:08:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$text = $response->content;
|
|
|
|
|
|
|
|
$text =~ m/<dt class="quote"><a.*?>(.*?)<\/a>.*?<dd class="author"><div.*?><a.*?>.*?<b>(.*?)<\/b>/g;
|
|
|
|
$t = "\"$1\" -- $2.";
|
|
|
|
|
2020-02-15 23:38:32 +01:00
|
|
|
my $quote = chr(226) . chr(128) . chr(156);
|
2009-12-09 02:08:12 +01:00
|
|
|
my $quote2 = chr(226) . chr(128) . chr(157);
|
2020-02-15 23:38:32 +01:00
|
|
|
my $dash = chr(226) . chr(128) . chr(147);
|
2009-12-09 02:08:12 +01:00
|
|
|
|
|
|
|
$t =~ s/<[^>]+>//g;
|
|
|
|
$t =~ s/<\/[^>]+>//g;
|
|
|
|
$t =~ s/$quote/"/g;
|
|
|
|
$t =~ s/$quote2/"/g;
|
|
|
|
$t =~ s/$dash/-/g;
|
|
|
|
$t =~ s/"/"/g;
|
|
|
|
$t =~ s/&/&/g;
|
|
|
|
$t =~ s/&nsb;/ /g;
|
|
|
|
$t =~ s/'/'/g;
|
|
|
|
$t =~ s/</</g;
|
|
|
|
$t =~ s/>/>/g;
|
|
|
|
$t =~ s/<em>//g;
|
|
|
|
$t =~ s/<\/em>//g;
|
|
|
|
|
2012-07-22 21:22:30 +02:00
|
|
|
print "$t\n";
|