aboutsummaryrefslogtreecommitdiffstats
path: root/writing_tools/random_line.pl
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2022-09-13 20:14:48 +0100
committerMatthew Lemon <matt@matthewlemon.com>2022-09-13 20:14:48 +0100
commit18588d5bbbb628c7aff04cbfb8b8ad5967c9bd7d (patch)
treeb44f4c6f31c268bbffbedcf6026336388735fbe0 /writing_tools/random_line.pl
parentbcac8134ea12369d6cf8ba7068ec78fd49a47223 (diff)
just create the md links
Diffstat (limited to 'writing_tools/random_line.pl')
-rw-r--r--writing_tools/random_line.pl17
1 files changed, 13 insertions, 4 deletions
diff --git a/writing_tools/random_line.pl b/writing_tools/random_line.pl
index fe19ab7..4723f0d 100644
--- a/writing_tools/random_line.pl
+++ b/writing_tools/random_line.pl
@@ -67,16 +67,25 @@ foreach my $line (@targetlines) {
}
}
+# get rid of duplicates from array or urls
+# see perlfaq4
+my %riddups = map { $_, 1 } @urls;
+my @uniqueurls = keys %riddups;
-foreach my $url (@urls) {
- print "URL: $url\n";
+sub create_mdlink {
+ my ($url, $title) = @_;
+ return "[".$title."]"."(".$url.")"
+
+}
+
+foreach my $url (@uniqueurls) {
my $req = HTTP::Request->new(GET => $url);
$req->header(Accept => "text/html");
my $res = $ua->request($req);
my $p = HTML::HeadParser->new;
$p->parse($res->content) and print "not finished";
- print "TITLE:", $p->header('Title'), "\n";
- print "\n";
+ my $title = $p->header('Title');
+ print create_mdlink($url, $title), "\n";
}