Thread Links aus CSV/XML auslesen und auf Richtigkeit testen
(5 answers)
Opened by raz at 2012-07-13 12:30 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #!/usr/bin/perl use strict; use warnings; use LWP::Simple; use Text::CSV; my $csv=Text::CSV->new({sep_char => ';', allow_whitespace => 1}); while(my $line=<DATA>) { next if($line=~/^\s*#/); $csv->parse($line); my $url=($csv->fields())[1]; my $website=get($url); if( !defined $website ) { print "ERROR: $url\n"; } elsif( $website =~ /Produkt konnte nicht gefunden werden/ ) { print "FAILED: $url\n"; } else { print "FOUND: $url\n"; } } __DATA__ #Text; URL; Zahl text1; http://www.example.org; 1 text2; http://www.example.org; 2 text3; http://www.example.org; 3 text4; http://www.example.org; 4 text5; http://www.example.org; 5 Edit: unnötiges "eol =>" entfernt Last edited: 2012-07-13 13:52:19 +0200 (CEST) |