Created
September 3, 2014 22:26
-
-
Save gupul2k/71b94d3834bf706d697a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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