Advertisement
kijato

kozepfoku_felveteli_eljaras/kozponti_feladatsorok

Jun 26th, 2017
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.86 KB | None | 0 0
  1. use strict;
  2. use WWW::Mechanize;
  3.  
  4. my $url = "https://www.oktatas.hu/kozneveles/kozepfoku_felveteli_eljaras/kozponti_feladatsorok";
  5. my $mech = WWW::Mechanize->new();
  6.  
  7. #$mech->proxy(['http','https'],'http://xxx.xxx.xxx.xxx:xxxx/');
  8. print $mech->status()."\n";
  9. $mech->get($url) || die "$!";
  10. #die unless ($mech->success);
  11. #print $mech->content;
  12.  
  13. #https://www.oktatas.hu/kozneveles/kozepfoku_felveteli_eljaras/kozponti_feladatsorok/2002_evi_irasbeli
  14. #my @links = $mech->find_all_links( url_regex =>  qr/(20\d{2})_evi_irasbeli/i );
  15.  
  16. #https://www.oktatas.hu/kozneveles/kozepfoku_felveteli_eljaras/kozponti_feladatsorok/irasbeli2003ev
  17. #my @links = $mech->find_all_links( url_regex =>  qr/irasbeli(20\d{2})ev/i );
  18.  
  19. #https://www.oktatas.hu/kozneveles/kozepfoku_felveteli_eljaras/kozponti_feladatsorok/2007evi_6_8osztalyos
  20. #my @links = $mech->find_all_links( url_regex =>  qr/(20\d{2})evi_6_8osztalyos/i );
  21.  
  22. #https://www.oktatas.hu/kozneveles/kozepfoku_felveteli_eljaras/kozponti_feladatsorok/2004evi_9evfolyamra
  23. my @links = $mech->find_all_links( url_regex =>  qr/(20\d{2})evi_9evfolyamra/i );
  24. for my $link ( @links ) {
  25.     my $url = $link->url_abs;
  26.     print "Fetching $url ...\n";
  27.     $mech->get($url);
  28.     my @pdflinks = $mech->find_all_links( url_regex =>  qr/(.pdf|.doc)$/i );
  29.     for my $pdflink ( @pdflinks ) {
  30.         my $pdfurl = $pdflink->url_abs;
  31.         $pdfurl =~ /(\d{4})/;
  32.         my $ev = $1;
  33.         my $pdffilename = $pdfurl;
  34.         print "\t$pdffilename\n";
  35.         $pdffilename =~ s[^.+/][];
  36.         $mech->get($pdfurl, ':content_file' => "$ev-$pdffilename");
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement