Twitter Streaming in Python: cp949 codec -


i using tweepy gather data using streaming api.

here code , ran on acaconda command prompt. when streaming starts, returns tweets , after giving few tweets gives following error:

streaming started ... rt @ish10040: crack dealer released prison obama murders woman , 2 young kids… exception in thread thread-1: traceback (most recent call last):   file "c:\users\jae hee\anaconda2\lib\threading.py", line 801, in __bootstrap_inner     self.run()   file "c:\users\jae hee\anaconda2\lib\threading.py", line 754, in run     self.__target(*self.__args, **self.__kwargs)   file "c:\users\jae hee\anaconda2\lib\site-packages\tweepy\streaming.py", line 294, in _run     raise exception unicodeencodeerror: 'cp949' codec can't encode character u'\xab' in position 31: illegal multibyte sequence 

i believe has encoding used chcp 65001 deal issue not give solution!

here code

auth = tweepy.oauthhandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret)  api = tweepy.api(auth)   class mystreamlistener(tweepy.streamlistener):      def on_status(self, status):       print(status.text)      def on_error(self, status_code):         #returning false in on_data disconnects stream         if status_code == 420:             return false  def main():      mystreamlistener = mystreamlistener()     mystream = tweepy.stream(auth = api.auth, listener = mystreamlistener)       print "streaming started ..."      try:         mystream.filter(track=['obama'], async = true)     except:         print "error!"         mystream.disconnect()  if __name__ == '__main__':     main() 

all text produced , accepted through twitter api should encoded utf-8, code should using codec decode what's coming back.

see here: https://dev.twitter.com/overview/api/counting-characters


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -