简体   繁体   中英

Facing 401 Error while streaming tweets using python

The below image shows the code and error message .

I have pasted the code below

Code:

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


#consumer key, consumer secret, access token, access secret.
ckey=""
csecret=""
atoken=""
asecret=""

class listener(StreamListener):

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

    def on_error(self, status):
        print status

auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)

twitterStream = Stream(auth, listener())
twitterStream.filter(track=["car","python"])

Sample Image: Please help me I am stuck with this for a long time.

I haven't used this software but I believe the problem is that you haven't supplied a consumer key and consumer secret. This being the case you could refer to,

Getting twitter consumer key and secret

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM