I have the following code which I got from this tutorial:
from bs4 import BeautifulSoup
import requests
req=requests.get("http://www.aflcio.org/Legislation-and-Politics/Legislative-Alerts")
data=req.text
soup=BeautifulSoup(data)
letters=soup.find_all("div",class_="ec_statements")
print(letters)
I am getting the following error:
Traceback (most recent call last):
File ".\scr3.py", line 7, in <module>
print(letters)
File "C:\Users\adi\AppData\Local\Programs\Python\Python35\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 '\u2019' in position 7787: character maps to <undefined>
If I try to apply an encode('utf-8')
method to the letters
object, I get an attribute error saying "ResultSet object has no attribute encode".
Anyone knows a workaround to print the letters object? I am using Python 3.5 and BeautifulSoup 4 on Windows 7.