tweepy 인증 설정하기
영상에서 tweepy를 사용해 Streaming API로 Twitter 데이터를 수집하는 방법을 살펴봤어요. tweepy를 사용하려면 Twitter 인증을 위한 Twitter API 키가 필요합니다.
이 연습 문제에서는 tweepy에서 여러 객체를 불러오고, 패키지 인증을 설정해 보겠습니다.
API 키인 access_token, access_token_secret, consumer_key, consumer_secret는 이미 정의되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 소셜 미디어 데이터 분석하기
연습 안내
tweepy모듈에서OAuthHandler와API를 임포트하세요.consumer_key와consumer_secret를OAuthHandler에 전달하세요.access_token과access_token_secret로 액세스 토큰을 설정하세요.auth객체를 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(____)