Tweepy 시작하기

들어가며

Tweepy가 처음이라면, 이 문서를 참조하시는 것을 권장합니다. 이 문서의 목표는 여러분이 Tweepy를 어떻게 설정하고 롤링하는지 알게 되는 것입니다. 여기서는 세부적인 언급은 피할 것이며, 몇 가지 중요한 기초 사항들만 다룰 것입니다.

Hello Tweepy

import tweepy

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

public_tweets = api.home_timeline()
for tweet in public_tweets:
    print(tweet.text)

This example will download your home timeline tweets and print each one of their texts to the console. Twitter requires all requests to use OAuth for authentication. The Authentication documentation goes into more details about authentication.

API

API 클래스는 트위터의 모든 RESTful API 메소드에 대한 접근을 지원합니다. 각 메소드는 다양한 매개변수를 전달받고 적절한 값을 반환할 수 있습니다. 보다 자세한 내용은 API Reference 를 참고해주세요.

모델 (Models)

When we invoke an API method most of the time returned back to us will be a Tweepy model class instance. This will contain the data returned from Twitter which we can then use inside our application. For example the following code returns to us a User model:

# Get the User object for twitter...
user = api.get_user(screen_name='twitter')

모델에는 다음과 같이, 사용 가능한 데이터 및 메소드가 포함되어 있습니다:

print(user.screen_name)
print(user.followers_count)
for friend in user.friends():
   print(friend.screen_name)

모델에 대한 보다 자세한 내용은 ModelsReference(Original Link Missing)를 참고해주세요.