Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The regular expressions work because of luck, they are not solid. See the 'wrong regex' comments. Also, the <em>getstore(url, file)</em> method needs <a href="http://host.org/dir/file" rel="nofollow">http://host.org/dir/file</a> as argument 1 and <em>path/to/file.jpg</em> as argument 2.</p> <p>Here is a working version:</p> <pre><code>use WWW::Mechanize; use strict; use warnings; use LWP::Simple; my $ctime = time(); my $Home_page = 'www.condortk.com/'; my $output_file = "www.condortk.com-$ctime"; my $url = 'http://www.condortk.com/results.php?keyword=&amp;Buscar.x=4&amp;Buscar.y=7'; my $m = WWW::Mechanize-&gt;new(); $m-&gt;get( $url ) or die "unable to get $url"; my $Home_Con = $m-&gt;content; system( 'mkdir Images' ) if ( ! -d "Images" ); my $next = ''; my $page = ''; while ( $Home_Con =~ m/&lt;div class="producto"&gt;&lt;a href="([^"]*?)"/igs ) { # &lt;-- wrong regex #print "Loop 1 $1 \n"; $m-&gt;get( "http://www.condortk.com/$1" ); # &lt;-- wrong url my $list_content = $m-&gt;content; my $img_name = ''; my $img_folder = ''; my $image = ''; my $big_image = ''; while ( $list_content =~ m/&lt;div\s*class="nombre2"&gt;&lt;a\s*href="([^"]*?)"/igs ) { #print "Loop 2 $1 \n"; my $desc = ''; my $desc1 = ''; my $block = $Home_page . $1; $m-&gt;get( $1 ); my $content1 = $m-&gt;content; if ( $content1 =~ m/id="imgproducto"&gt;&lt;img src="([^&lt;]*?)"/is ) { $img_name = $1; # wrong url and 'save as' parameters if ( $img_name =~ m/\/\w+\/\w+\/(.*)$/is ) { my $basename = $1; my $get = "http://${Home_page}${img_name}"; my $save = "Images/$basename"; my $code = -1; if ( ! -f $save ) { $code = getstore($get, $save ); print "$get --&gt; $save : $code\n"; } else { print "Skipping $save\n"; } #if ($code != 200) { print "$get --&gt; Images/$save : $code\n"; } } } } } </code></pre> <p>-</p> <pre><code>$ perl dl.img.pl http://www.condortk.com/.../60504s_725x0.jpg --&gt; Images/Images/60504s_725x0.jpg : 200 http://www.condortk.com/.../60508s_725x0.jpg --&gt; Images/Images/60508s_725x0.jpg : 200 http://www.condortk.com/.../60501s_725x0.jpg --&gt; Images/Images/60501s_725x0.jpg : 200 http://www.condortk.com/.../60020s_725x0.jpg --&gt; Images/Images/60020s_725x0.jpg : 200 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload