Search code examples
pythontwittertwitter-search

Errors when I collect tweets using twitter API


I'm using tweetminer to collect tweets from this site: https://github.com/kshaffer/tweetmineR

but when I run the search using twitter_search.py I get those errors:

<undefined>
'charmap' codec can't encode character '\u06cc' in position 196: character maps to <undefined>
'charmap' codec can't encode character '\U0001f43c' in position 88: character maps to <undefined>
'charmap' codec can't encode character '\u06cc' in position 210: character maps to <undefined>

They aren't exactly errors, but the search will continue. But there's a lot of them get printed on the console. How to resolve them?


Solution

  • You can try to add the parameter encoding='utf-8' each time you use open() (lines 41 and 48). Or apply .encode('utf-8') to the tweets you collect.