Permalink
Browse files

.

  • Loading branch information...
1 parent 176dfc0 commit a9afed6d40ec44dd6f6c53af0f31de61f602d9b0 @gugod committed Dec 21, 2011
Showing with 29 additions and 0 deletions.
  1. +29 −0 magnet-links
View
29 magnet-links
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+#
+# Find and print magnet links in a given page.
+#
+
+use v5.14;
+use utf8;
+use File::Basename;
+use WWW::Mechanize;
+
+binmode STDOUT, ":utf8";
+
+unless (@ARGV) {
+ die "\nUsage: " . basename($0) . " URL [pattern]\n\n";
+}
+
+my $url = shift @ARGV;
+my $wanted = shift @ARGV || qr/\S/;
+
+my $ua = WWW::Mechanize->new;
+$ua->get($url);
+
+for ($ua->links) {
+ next unless $_->url =~ /magnet:/;
+ next unless $_->text =~ /$wanted/;
+
+ say "# " . $_->text;
+ say $_->url;
+}

0 comments on commit a9afed6

Please sign in to comment.