I'm making a Twitter API, I get tweets about a specific word (right now it's 'flafel'). Everything is fine except this tweet
b'And when I\'m thinking about getting the chili sauce on my flafel and the waitress, a Pinay, tells me not to get it cos "hindi yan masarap."\xf0\x9f\x98\x82'
I use print ("Tweet info: {}".format(str(tweet.text).encode('utf-8').decode('utf-8')))
to see tweets, but this one gives me UnicodeEncodeError every time and if I erase decode()
from that line like print ("Tweet info: {}".format(str(tweet.text).encode('utf-8'))
I can see the actual tweet like above, but I want to convert that \xf0\x9f\x98\x82
part to a str. I tried everyting, every version of decodes-encodes etc. How can I solve this problem?
Edit: Well I just went to that user's Twitter account to see what is that non-ASCII part, and it turns out it's a smile:
Is it possible to convert that smiley?
Edit2: The codes are;
...
...
api = tweepy.API(auth)
for tweet in tweepy.Cursor(api.search,
q = "flafel",
result_type = "recent",
include_entities = True,
lang = "en").items():
print ("Tweet info: {}".format(str(tweet.text).encode('utf-8').decode('utf-8')))