Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # version 1.1 need to add description item and the shipping times
- #!/usr/bin/perl -w
- use Data::Dumper;
- use HTTP::Cookies;
- use LWP::UserAgent;
- use LWP::Simple;
- use strict;
- $| =1;
- my $browser;
- my $htmlpage;
- my $profitRate = 1.6;
- sub startBrowser{
- $browser = LWP::UserAgent->new(
- agent=>'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/1.5.0.5',
- # cookie_jar => $cookie_jar,
- max_redirect => 0,
- timeout =>15,
- );
- }
- sub getURL{
- my $url = $_[0];
- my $resp = $browser->get($url);
- my $content = $resp->content(); #make content store web scoure
- #print $content;
- return $content;
- }
- sub getInfo{
- my ($photoUrl,
- $nameProduct ,
- $description,
- $shipingtime,
- $dirName,
- $minPrice,$maxPrice,$sellPrice,
- );
- $photoUrl = 'imageBigViewURL=\[\s+(\"[\w:\/\/\\.\-\"\,\s]+"\s+])';
- $nameProduct = 'product-name.*>(.*)<';
- my @itemsOption = ('<span.*?>([\w\s]+)</span></a></li>', '.jpg"\s+title="([\w\s]+)"\s');
- $minPrice = $htmlpage =~ /minPrice="(\d+.\d+)"/g; $minPrice = $1;
- $maxPrice = $htmlpage =~ /maxPrice="(\d+.\d+)"/g; $maxPrice = $1;
- $sellPrice = $maxPrice * ($profitRate + 0.1); # estimated fee + risk as 10% of selling prices.
- if ($htmlpage =~ /$nameProduct/){
- $nameProduct = $1; $dirName = $nameProduct =~ s/[\s\,]/\_/gr;
- print "[+]The product:".$nameProduct."\n";
- system("mkdir $dirName && cd $dirName && echo $nameProduct >> Product.txt && echo - >> Product.txt && echo minPrice:$minPrice maxPrice:$maxPrice >> Product.txt && echo Sell@ : $sellPrice >> Product.txt && mkdir images");
- } else { print "[-]Name product no found \n"; }
- if ( $htmlpage =~ /$itemsOption[0]/g ) {
- my @choice = ($htmlpage =~ m/$itemsOption[0]/g );
- @choice[scalar(@choice)] = $htmlpage =~ /$itemsOption[0]/g;
- my @reOrdre;
- $reOrdre[0] = @choice[scalar(@choice)-1];
- for (my $i =0; $i<scalar(@choice)-1;$i++) {
- $reOrdre[$i+1] = $choice[$i];
- }
- foreach (@reOrdre) { #span choices
- print "[+] choices :";
- print "$_ \n";
- system("cd $dirName && echo $_ >> options.txt");
- if ($htmlpage =~ /$itemsOption[1]/g ) {
- my @choice = ($htmlpage =~ m/$itemsOption[1]/ig );
- @choice[scalar(@choice)] = $htmlpage =~ /$itemsOption[1]/g;
- my @reOrdre;
- $reOrdre[0] = @choice[scalar(@choice)-1];
- for (my $i =0; $i<scalar(@choice)-1;$i++) {
- $reOrdre[$i+1] = $choice[$i];
- }
- foreach (@reOrdre) { #images choices
- print "[+] choices option:";
- print "$_ \n";
- system("cd $dirName && echo $_ >> options.txt"); }
- }
- } }
- elsif ($htmlpage =~ /$itemsOption[1]/ig) {
- my @choice = ($htmlpage =~ m/$itemsOption[1]/ig );
- @choice[scalar(@choice)] = $htmlpage =~ /$itemsOption[1]/g;
- my @reOrdre;
- $reOrdre[0] = @choice[scalar(@choice)-1];
- for (my $i =0; $i<scalar(@choice)-1;$i++) {
- $reOrdre[$i+1] = $choice[$i];
- }
- foreach (@reOrdre) { #images choices
- print "[+] choices :";
- print "$_ \n";
- system("cd $dirName && echo $_ >> options.txt"); }
- }
- else { print "[~][+]There is no choices \n"}
- if($htmlpage =~ /$photoUrl/)
- {
- $photoUrl = $1;
- print $photoUrl;
- print "Start collecting photos:\n";
- my @imageUrl = $photoUrl =~ /\"(.*.jpg)\"[,\s]/ig;
- for (my $i = 0; $i < scalar(@imageUrl); $i++ ) {
- print $imageUrl[$i]."\n";
- if (is_success(getstore($imageUrl[$i], $dirName.'\\images\\'.$i.'.jpg'))) { # !!!!!!!!!!!!! warning won't download file if file directory no found !
- print "Success\n";
- } else { print "failed \n"; }
- }
- }
- print "[+]finished \n";
- }
- #============================================================================== start ============================================================
- startBrowser();
- print "Link: ";
- chop (my $link = <stdin>);
- $htmlpage = getURL($link);
- #$htmlpage = getURL('');
- getInfo();
- sleep();
- system("pause");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement