Reputation: 1365
I tried to fetch some info from a website but got this instead .
here is the code..
import requests
r = requests.get("http://erp.college_name.edu/").text
print(r)
and here is the error..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Programs\Python\Python35-
32\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in
position 7435: character maps to <undefined>
i am trying to login to my id using requests.
any help?
Upvotes: 3
Views: 4056
Reputation: 81
You can encode the text with 'utf-8', then the string can be print out correctly.
import requests
r = requests.get("http://erp.college_name.edu/").text
print(r.encode('utf-8'))
Upvotes: 4