Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Discogs Python API Client
import urllib2, gzip, cStringIO
url = 'http://www.discogs.com/release/123?f=xml&api_key=1111'
headers = {'Accept-Encoding': 'gzip', 'User-Agent': 'MyDiscogsClient/1.0 +http://mydiscogsclient.org'}
request = urllib2.Request(url, None, headers)
try:
response = urllib2.urlopen(request)
data = response.read()
try:
data = gzip.GzipFile(fileobj = cStringIO.StringIO(data)).read()
except IOError:
pass
except urllib2.HTTPError, e:
data = e.read()
print data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.