शुरू करेंमुफ़्त में शुरू करें

Setting up tweepy authentication

In the video, we saw how tweepy can be used to collect Twitter data with the Streaming API. tweepy requires a Twitter API key to authenticate with Twitter.

In this exercise, you will load several objects from tweepy and set up the authentication for the package.

The API keys access_token, access_token_secret, consumer_key, and consumer_secret have already been defined for you.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Analyzing Social Media Data in Python

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Import OAuthHandler and API from the tweepy module.
  • Pass consumer_key and consumer_secret to OAuthHandler.
  • Set the access tokens with access_token and access_token_secret.
  • Pass the auth object to the API.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

from ____ import ____
from ____ import ____

# Consumer key authentication
auth = OAuthHandler(____, ____)

# Access key authentication
auth.set_access_token(____, ____)

# Set up the API with the authentication handler
api = API(____)
कोड संपादित करें और चलाएँ