Retrieving Content from Twitter
In this unit, you'll learn how to set up and authenticate the Twitter API in order to retrieve content from public Twitter accounts.
StartUsing the Twitter API
Lesson 1 of 1
- 2Before we can interact with the Twitter API, we’ll need to import the following Python packages: * sys - a basic interpreter that can handle low level functions of the computer’s operating system….
- 3Now that we have the basic setup in our file, it’s time to start retrieving some data from Twitter. Before we can interact with the Twitter API, we need to authenticate with the Twitter API. To d…
- 4To interact with the Twitter API, we first need to create an instance of the Twitter package we imported earlier. We can do this by calling the .Api() method on the twitter package and setting…
- 5Great! But to retrieve data from Twitter, we need to make an actual call to the API. So far, we’ve only created the object (twitter_api)that represents the Twitter API we’ll interact with. To ma…
- 6We’ve done a lot of work, but we still haven’t seen any data from Twitter. Let’s fix that! The GetUserTimeline() method returns will return data from Twitter in the form of a Python list , so we …
- 7The data we retrieve from Twitter doesn’t include just tweets, it also contains a lot of metadata . Unfortunately, the metadata contains information that we won’t use (i.e., when the tweet was c…
- 8Great! Now that we have the text we need, it’s time to prepare it so that we can send it to the Personality Insights (PI) API for analysis. First, we’ll concatenate the text into one long string…