diff options
Diffstat (limited to 'Imdb.py')
-rw-r--r-- | Imdb.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +#!/usr/bin/env python +# -*- coding: iso-8859-1 -*- + +from urllib2 import urlopen +from json import loads +from urllib import quote_plus +from re import findall + +def titleCode(title): + try: + html = urlopen("http://www.imdb.com/find?s=tt&q=" + quote_plus(title)).read() + except: + return "" + titleCodes = findall("/title/tt([0-9]{7})/", html) + if len(titleCodes) > 0: + return titleCodes[0] + else: + return ""
\ No newline at end of file |