1 00:00:00,720 --> 00:00:02,140 - [Instructor] In this self check exercise 2 00:00:02,140 --> 00:00:04,390 I'd like you to use a cursor object 3 00:00:04,390 --> 00:00:07,060 as I demonstrated in the preceding video 4 00:00:07,060 --> 00:00:09,950 this time to get and display ten followers 5 00:00:09,950 --> 00:00:13,571 for the NASAKepler account that you used 6 00:00:13,571 --> 00:00:17,780 in the preceding self check exercise. 7 00:00:17,780 --> 00:00:21,300 So go ahead and pause the video and give that a shot 8 00:00:21,300 --> 00:00:23,200 then come back here to see the answer. 9 00:00:27,950 --> 00:00:32,210 Okay first step is going to be to create the list 10 00:00:32,210 --> 00:00:36,250 in which you're going to store the actual user names 11 00:00:36,250 --> 00:00:37,770 that come back. 12 00:00:37,770 --> 00:00:40,275 Then we of course need to set up the Tweepi cursor. 13 00:00:40,275 --> 00:00:44,430 Again we'll be calling the API objects followers method 14 00:00:44,430 --> 00:00:47,660 this time however we're going to pass to that method 15 00:00:47,660 --> 00:00:51,600 the NASAKepler account as the argument. 16 00:00:51,600 --> 00:00:54,670 So once you have that cursor remember that it is lazy 17 00:00:54,670 --> 00:00:57,960 and it doesn't do anything until you iterate over it 18 00:00:57,960 --> 00:00:59,480 and the way you start to do that 19 00:00:59,480 --> 00:01:02,520 is by calling the cursor's items method. 20 00:01:02,520 --> 00:01:04,080 The cursor's items method 21 00:01:04,080 --> 00:01:05,930 is going to receive as it's argument 22 00:01:05,930 --> 00:01:08,448 the number of total items you would like to get 23 00:01:08,448 --> 00:01:13,448 and again it will manage not only invoking the Twitter API 24 00:01:14,538 --> 00:01:17,680 over the internet for you 25 00:01:17,680 --> 00:01:21,460 but it will work in if you've configured the API object 26 00:01:21,460 --> 00:01:25,130 to wait on rate limits doing the automatic waiting for you. 27 00:01:25,130 --> 00:01:29,312 So depending on how many accounts you're actually requesting 28 00:01:29,312 --> 00:01:32,440 to get followers for the Kepler account here, 29 00:01:32,440 --> 00:01:35,330 this loop could take a very long time to execute 30 00:01:35,330 --> 00:01:39,820 if you hit those rate limits for a 15 minute interval. 31 00:01:39,820 --> 00:01:41,630 So for each of the accounts that we get 32 00:01:41,630 --> 00:01:43,160 we're going to grab that screen name 33 00:01:43,160 --> 00:01:44,460 and append it to the list. 34 00:01:44,460 --> 00:01:46,210 So I'll go ahead and execute that. 35 00:01:46,210 --> 00:01:49,453 And by the way when you execute those API calls, 36 00:01:49,453 --> 00:01:51,140 those API object calls, 37 00:01:51,140 --> 00:01:52,670 remember there could be delays 38 00:01:52,670 --> 00:01:55,920 because those are making requests over the internet 39 00:01:55,920 --> 00:01:57,839 so things like your connection speed 40 00:01:57,839 --> 00:02:02,120 could affect how fast results come back to you. 41 00:02:02,120 --> 00:02:04,150 And then finally we're going to join together 42 00:02:04,150 --> 00:02:06,080 by spaces the followers. 43 00:02:06,080 --> 00:02:10,080 In this case we didn't bother to sort them alphabetically 44 00:02:10,080 --> 00:02:13,923 we simply concatenated them for display purposes.