[San-Diego-pm] Photo download problem

Chris Grau chris at chrisgrau.com
Sun Aug 22 14:24:49 PDT 2010


> http://fentin.com/cgi-bin/temp.pl
[snip]

> Wikimedia permits the downloading of photos and hotlinking. Yet I
> can't get it to do anything with perl. The two URLs above (same photo
> in each case) work in the FF browser. The third example is from my own
> website as test. It downloads content.

I seem to have the opposite results when running your test code.  I
receive an error attempting to download wikimedia's content (trimmed):

    $ HEAD http://upload.wikimedia.org/wikipedia/commons/1/19/PacificSilverFir_7645.jpg
    403 Forbidden
    X-Squid-Error: ERR_ACCESS_DENIED 0

They must be blocking LWP's user agent, because wget works fine.  I
didn't bother testing a modified user agent string in LWP.

> $f = 'http://commons.wikimedia.org/wiki/File:PacificSilverFir_7645.jpg';
> $Content2 = get($f);
> print length($Content2)."<br>";
>
> $f = 'http://upload.wikimedia.org/wikipedia/commons/1/19/PacificSilverFir_7645.jpg';
> $Content2 = get($f);
> print length($Content2)."<br>";
>
> $f = 'http://fentin.com/Ecuador/B_Tuncarta-Children.jpg';
> $Content2 = get($f);
> print length($Content2)."<br>";
> print "<BR>DONE";

What are you trying to accomplish?  All three get() statements
theoretically download the content of the URL.  In fact, running your
script, the file on your website was the only one to successfully
download (again, the apparent user agent problem).


More information about the San-Diego-pm mailing list