hd1

hd1/flickrstupidity2

hd1
May 12th, 2015
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.69 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;use diagnostics;use warnings;
  3. use Getopt::Long;
  4. use HTML::TreeBuilder;
  5. use LWP::Simple;
  6. use File::Temp;
  7.  
  8. our $url;
  9. GetOptions('--url=s' => \$url) or die("Error in command line arguments\n");
  10.  
  11. die "invalid url" unless $url =~ m@^http(s)?://www.flickr.com/photos/@;
  12.  
  13. my $h = HTML::TreeBuilder->new_from_url($url);
  14. my $image_uri = $h -> look_down('_tag' => 'link', 'rel' => 'image_src', sub {
  15.     return $_[0]->attr('href');
  16.                                 });
  17.  
  18. my $data = get( $image_uri->{'href'});
  19. my $fh = File::Temp->new(TEMPLATE => 'flickrXXXXXXXXXX', UNLINK => 0, SUFFIX=>'.jpg');
  20. my $outfile = $fh->filename;
  21. print $fh "$data";
  22. close $fh;
  23. print "$url saved to $outfile!\n";
Advertisement
Add Comment
Please, Sign In to add comment