AllFreePapers.com - All Free Papers and Essays for All Students
Search

Imdb Python Api

Autor:   •  June 15, 2011  •  Study Guide  •  1,084 Words (5 Pages)  •  1,532 Views

Page 1 of 5

import pycurl, random, sys, os

curl = pycurl.Curl()

outfile = file("output.html", "w")

curl.setopt(pycurl.USERAGENT, 'Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)')

curl.setopt(pycurl.WRITEDATA, outfile)

def get_tid(title):

outfile = file("output.html", "w")

curl.setopt(pycurl.URL, 'http://www.imdb.com/find?s=tt&q=' + title)

curl.perform()

outfile.close()

infile = file("output.html", "r")

testLine = """title_popular/images/b.gif?link=/title/"""

for line in infile:

ar = line.split(testLine)

if len(ar) > 1:

title = ar[1].split('/')

infile.close()

return title[0]

def get_aid(name):

outfile = file("output.html", "w")

curl.setopt(pycurl.URL, 'http://www.imdb.com/search/name?name=' + name)

curl.perform()

outfile.close()

infile = file("output.html", "r")

testLine = """<a href="/name/"""

for line in infile:

ar = line.split(testLine)

if len(ar) > 1:

name = ar[1].split('/')

infile.close()

return name[0]

def get_actors(titleID):

outfile = file("output.html", "w")

curl.setopt(pycurl.URL, 'http://www.imdb.com/title/' + titleID + '/fullcredits')

curl.perform()

outfile.close()

infile = file("output.html", "r")

outText = []

prefixLine = """td class="nm"><a href="""

...

Download as:   txt (5.9 Kb)   pdf (98.3 Kb)   docx (12.2 Kb)  
Continue for 4 more pages »