When the content-type
of the server is \'Content-Type:text/html\'
, requests.get()
returns improperly encoded data.
However, if
After getting response, take response.content
instead of response.text
and that will be of encoding utf-8
.
response = requests.get(download_link, auth=(myUsername, myPassword), headers={'User-Agent': 'Mozilla'})
print (response.encoding)
if response.status_code is 200:
body = response.content
else:
print ("Unable to get response with Code : %d " % (response.status_code))