Skip to content

Instantly share code, notes, and snippets.

@hjortron
Last active August 29, 2015 14:10
Show Gist options
  • Save hjortron/c0aaa59140420a3b2a59 to your computer and use it in GitHub Desktop.
Save hjortron/c0aaa59140420a3b2a59 to your computer and use it in GitHub Desktop.
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;
@Fi5t
Copy link

Fi5t commented Dec 5, 2014

It's awersome script! =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment