I'm learning how to parse HTML using Beautiful Soup. I've been working with NetBeans as IDE in a virtual environment (Python 3.6) and I had no problems.
My surprised was when trying a very simple code in order to find all the 'a' elements from a web site I got an error. If I tried to select all 'h3' or any other element it works but not when I try with 'a'.
import requests
import bs4
url = 'https://www.python.org/events/'
req = requests.get(url)
req.raise_for_status()
reqText = req.text
soup = bs4.BeautifulSoup(reqText, "html.parser")
selection1 = soup.find_all('a')
print(selection1)
The error says:
Traceback (most recent call last):
File "C:\PROJECTS\Python36\src\new_main.py", line 9, in <module>
print(selection)
File "C:\Anaconda2\envs\env1a\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u25bc' in position 211: character maps to <undefined>
I have another IDE installed (Spyder) and it worked when using it.
It looks like it's a problem with codecs. Could anybody tell me how can I fix this problem. Why Netbeans fails when selecting a very specific element and it works otherwise.