I want to grab a bit of information from IMDB.

I can do this with LWP::UA by with something like this:

my $ua = LWP::UserAgent->new; my $response = $ua->get('http://imdb.com/find?nm=on;mx=20;q=eliza%20dushku');

and if I do that with a name that exactly matches something in IMDB's database, it will redirect the browser to another URL, in this case http://imdb.com/name/nm0244630/

Now I can parse the information in that page to get what I want, but actually, all I need is this person's IMDB URL, so if I could figure out whether their server returned a Location: header which send the browser to this URL, that would save unneccessary processing.

If this doesn't happen of course, (and the URL remains "http://imdb.com/find?nm=on;mx=20;q=liza%20dushku" because you got her name wrong) I need to do some further processing. But what I really want is something like this pseudocode:

my $response = $ua->get('http://imdb.com/find?nm=on;mx=20;q=eliza%20dushku'); if($response included a relocation to a URL){ store that URL } else { do the more complicated stuff }
Any ideas?


($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print

In reply to How to tell if a URL returned a Location: header? by Cody Pendant

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.