# If the response has Content-Disposition, we take file name from it
filename = response.info()['Content-Disposition'].split('filename=')[1].decode('utf-8')
if filename[0] == '"' or filename[0] == "'":
filename = urllib2.unquote(filename.split('"')[1])
else:
# If the response has Content-Disposition, we take file name from it
filename = response.info()['Content-Disposition'].split('filename=')[1].decode('utf-8')
if filename[0] == '"' or filename[0] == "'":
filename = urllib2.unquote(filename.split('"')[1])
else: