Last active
August 29, 2015 14:10
-
-
Save hjortron/c0aaa59140420a3b2a59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Mojo::DOM; | |
use WWW::Mechanize; | |
my $mech = WWW::Mechanize->new( autocheck => 0 ); | |
open my $outfh, ">", "out.csv" or die $!; | |
open (csvFile,'F:/tmp/3dcart list.csv') || die "Failed to open CSV file: $!\n"; | |
while (<csvFile>){ | |
chomp($_); | |
my @f = split /,/,$_, -1; | |
my @adreses = split /;/,$f[12]; | |
foreach my $adres(@adreses){ | |
my $url="http://www.$adres/product_index.asp"; | |
print ("$url\n"); | |
$mech->get($url); | |
if ( $mech->success() ) { | |
my $cont = $mech->content; | |
my $dom = Mojo::DOM->new($cont); | |
my $element = $dom->find('a[href^=product_index.asp?page=]')->last; | |
if ($element){ | |
my $column = $element->text; | |
if($column >10){ | |
print $outfh $_.$column; | |
print $outfh "\n"; | |
} | |
} | |
} | |
} | |
} | |
close csvFile or die "file.csv: $!"; | |
close($outfh); | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's awersome script! =)