Hello, I am trying to use LWP to print out an image. When I put the URL in the browser, it properly returns the image. When I use LWP, it returns a different representation of the image and all I see if special characters. Here is the URL that I call that returns a map if you put it in the browser.
http://xml.sa.mapquest.com:80/?transaction=mapimage&datalen=153&data=7 +1e3Q01g%7EgHl04e%28cN1os1%22%3E0wR3KkDxayw%7CY%25+0As9wU75kgit%24TU%3 +Dna%3FH%3EJh9FL7nFsU40%5DltBFj%3A%2Bv%26b%7B2Ys2xuSx%23kMobGl%2B+tvDh +BP%23%2CbF8b29
Here is the code I use to try to get Perl to print out the same image. I stole this code from a seperate thread here on perlmonks.com. I wrote my own code and got the same result.
my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $mapURL = "http://xml.sa.mapquest.com:80/?transaction=mapimage&datalen +=153&data=71e3Q01g%7EgHl04e%28cN1os1%22%3E0wR3KkDxayw%7CY%25+0As9wU75 +kgit%24TU%3Dna%3FH%3EJh9FL7nFsU40%5DltBFj%3A%2Bv%26b%7B2Ys2xuSx%23kMo +bGl%2B+tvDhBP%23%2CbF8b29" my $response = $ua->get($mapURL, 'User-Agent' => 'Mozilla/5.0 [en] (Windows; U; Windows NT 6.0)', 'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, i +mage/png, */*', 'Accept-Charset' => 'iso-8859-1,*,utf-8', 'Accept-Language' => 'en-US', ); if ($response->is_success) { print $response->content; }
Thanks in advance for whatever suggestions you may have for me.

In reply to Error Using LWP to display an image by Hammy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.