This forum is now read-only. Please use our new forums at

The NPR API Forum

View Course » View Exercise

667 points
Submitted by
Steven McDermott
almost 5 years ago

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 = ''
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 =
    my_feed = open('my_feed.xml', 'w')
    output = my_feed.write(output)

    print "You must enter an NPR ID, a search term, or both."

1 vote


same happened with me, same systems too!

645 points
Submitted by
almost 5 years ago

1 Comment

531927639c4e9dc99500071d_94953626 Steven McDermott almost 5 years ago

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.