This forum is now read-only. Please use our new forums at discuss.codecademy.com.
cant view xml file
I cannot view the xml output file on this exercise. Anyone else having this problem? Using chrome on windows 7 pro x64
here is my code, is something wrong? The exercise passed me and i dont see anything wrong myself.
from urllib2 import urlopen
from urllib import quote
key = "API_KEY"
url = 'http://api.npr.org/query?apiKey='
url += key
url += '&requiredAssets=audio'
url += '&format=Podcast'
url += '&numResults=3'
url += '&action=Or'
npr_id= raw_input("Enter comma-separated NPR IDs or leave blank.")
search_string = raw_input("Enter your search string or leave blank.")
feed_title = raw_input("What's your feed title?")
if npr_id or search_string == True:
raw_input("Hit Enter to download your podcast.")
if npr_id:
url += '&id=' + npr_id
if search_string:
url += '&searchTerm=' + quote(search_string)
if feed_title:
url += '&title=' + feed_title
response = urlopen(url)
output = response.read()
my_feed = open('my_feed.xml', 'w')
output = my_feed.write(output)
my_feed.close()
else:
print "You must enter an NPR ID, a search term, or both."
1 Comment
if you go to npr's website and just register for an API key you can run these outside of code academy to see the files.