Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: Perl  |  size: 0.57 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use utf8;
  6. use WWW::Mechanize;
  7. use vars qw(@links);
  8.  
  9.  
  10. my $mech = WWW::Mechanize->new( agent => 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0' );
  11. for (my $i = 800; $i >= 0; $i -= 20) {
  12.     $mech->get("http://diary.ru/~narven-aegilwen?from=$i");
  13.     push @links, $mech->find_all_links(text => 'URL');
  14. }
  15.  
  16.  
  17. foreach my $link (@links) {
  18.     my $filename = $link->url_abs()->path();
  19.     $filename =~ s[/][];
  20.     $mech->get($link, ':content_file' => "E:\\diary\\$filename");
  21.     print $filename . "\n";
  22. }