I'm running a pretty simple script in Python to get data from a URL:
import urllib2
from bs4 import BeautifulSoup
def get_data():
response = urllib2.urlopen('http://www.p2016.org/photos15/summit/trump012415spt.html')
html = BeautifulSoup(response, 'html.parser')
text = html.get_text()
return text
print get_data()
I keep getting this error message:
PS C:\Users\Ben\pythonlearning\markov_chain> python fetch_data.py
Traceback (most recent call last):
File "fetch_data.py", line 11, in <module>
print get_data()
File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xa9' in position 22825: character maps to <undefined>
I've tried:
- running it without the print command, and I get no error
- having someone on another computer run the exact same code, and it works.