Skip to content

Instantly share code, notes, and snippets.

@gupul2k
Created September 3, 2014 22:26
Show Gist options
  • Save gupul2k/71b94d3834bf706d697a to your computer and use it in GitHub Desktop.
Save gupul2k/71b94d3834bf706d697a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python27
#Importing the modules
import sys
import urllib2
import re
import json
#Ask for movie title
title = raw_input("Please enter a movie title: ")
#Ask for which year
year = raw_input("which year? ")
#Search for spaces in the title string
raw_string = re.compile(r' ')
#Replace spaces with a plus sign
searchstring = raw_string.sub('+', title)
#Prints the search string
print searchstring
#The actual query
url = "http://www.imdbapi.com/?t=" + searchstring + "&y="+year
request = urllib2.Request(url)
response = json.load(urllib2.urlopen(request))
print json.dumps(response,indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment