Twitter streaming API keyword filter in traditional Chinese and location filter



Hi gurus,

(1) I prepared the following Python 2.7.6 and tweepy.streaming scripts to download live tweets. If the keyword in English, it works fine. However, if the keyword is in traditional Chinese, the following error messages will show up.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xa5 in position 0: ordinal not in range(128)

May I know if there is any way to fix this issue?

(2) May I know if there is anyway to only collect the tweets from Taiwan? My understanding is to use “locations=['parameter value”’]". Is there anywhere we can lookup the location parameter value of Taiwan?

   # -*- coding: cp950 -*-

   from tweepy.streaming import StreamListener
   from tweepy import OAuthHandler
   from tweepy import Stream

   #Variables that contains the user credentials to access Twitter API 
   access_token = "...."
   access_token_secret = "...."
   consumer_key = "...."
   consumer_secret = "...."

   #This is a basic listener that just prints received tweets to stdout.
   class StdOutListener(StreamListener):

       def on_data(self, data):
           print data
           return True

       def on_error(self, status):
           print status

   if __name__ == '__main__':

       #This handles Twitter authetification and the connection to Twitter Streaming API
       l = StdOutListener()
       auth = OAuthHandler(consumer_key, consumer_secret)
       auth.set_access_token(access_token, access_token_secret)
       stream = Stream(auth, l)

       #This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby'
       stream.filter(track=['你好'], languages=['zh-tw'], locations=['Taiwan'])