Last night, I wrote a script which performs a search for a given string on www.imdb.org/com and returns the full title + rating from that movie. It resulted in a 4-liner which was more than 80 columns width. Luckily, Juerd was willing to take a look at it, resulting in the following code:
use LWP::Simple;$_=get"http://imdb.com/Find?for=$ARGV[0 ]&select=All";$_=get"http://imdb.com/Title?$1"if m!LI>< A\sHREF="/Title\?(\d+)">.+?</A>!ix;m!<BASE\sHREF="http: //.+?/Title\?(\d+)">!i;($t)=/<TITLE>(.+?)<\/TITLE/ix;($ r)=m!<B>([\d\.]+)</B>/\d+!i;$r||='?';print"$t: $r/10\n"
It takes 1 argument - the string to search for.

Replies are listed 'Best First'.
(jeffa) Re: IMDB Fetcher
by jeffa (Bishop) on Jan 26, 2002 at 21:29 UTC
    Well hell's bells!

    Kinda makes mine look a little silly, weighing in at 200 lines. Then again, I plan on submitting mine as a CPAN module (i use HTML::TokeParser to exract the info). The trick is getting the movie with as little page hits as necessary - if the user knows the ID number then you should be able to retrieve the goods with one page hit.

    Thanks for posting ... i still have a lot of work to do on mine.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      I'm glad to hear about this... I've been working on Perl-ish version of a roundabout movie trivia game I learned in high school. Great for road trips or late nights at Denny's :p. I was hand-rolling all the interfact to the IMDb though, this will hopefully save me a lot of work.

      "We're experiencing some Godzilla-related turbulence..."

Re: IMDB Fetcher
by hossman (Prior) on Jan 27, 2002 at 00:58 UTC
    I'd be remiss if I didn't mention that it's possible to do this without fetching/parsing any data from www.imdb.com. For years the IMDB folks have provided all of their movie data free of charge. You can download the datafiles from ftp.imdb.org (They're updated about once a week). They also provide software for doing commandline searches (plus a GUI for windows users, but i've never tried it)

    If you do more then a couple of searches a day, it's worth having.

      Problem is, is that IMDB now licence their data and charge for it (even though the prices aren't on the site).
        I'm pretty sure they've allways charged to licence their data.

        If you're surfacing it on another site, I don't think t hey're going to care if you're using their tools, a Module from CPAN, or a homegrown perl script -- they're still going to want their licencing fee.

        But if you're doing queries for personal use, you might as well havea local copy of all the data instead of going across the pipe and parsing the HTML everytime.

Re: IMDB Fetcher
by Juerd (Abbot) on Jan 26, 2002 at 16:57 UTC
    This is not obfuscated. Go see other code in the Obfuscation section.
    Removing whitespace and brackets/parens doesn't obfuscate, that just makes it harder to read (yes, I know that's a contradiction).
    Most monks will probably be interested in the original, clear and readable version more.

    2;0 juerd@ouranos:~$ perl -e'undef christmas'
    Segmentation fault
    2;139 juerd@ouranos:~$