knilssen / Founding_Fathers

Provides a reliable political feed for readers to become knowledgeable and informed voters on the state political level.
https://knilssen.github.io/Founding_Fathers
1 stars 1 forks source link

'ascii' codec can't encode character u'/u2014' #5

Closed knilssen closed 7 years ago

knilssen commented 7 years ago

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 0: ordinal not in range(128)

Error in personOfInterestWeightWithInputs.py at line 60 firstItem = (str(item[0])).strip(")('?.,:")

This is the first time I have encountered this error. It has only happened with this article and keyword. This error occurs with the parameters: python personOfInterestWeightWithInputs.py 'http://www.cnn.com/2017/02/04/politics/us-protests-trump/index.html' "Donald J. Trump"

knilssen commented 7 years ago

Temporarily fixed by just testing for the u'\2014'.

if item[0] == u'\u2014': firstItem = (item[0]).strip(")('?.,:") else: firstItem = (str(item[0])).strip(")('?.,:")

If this is the only error we come across, perfect. This will need something else to check for.