From d9b59b3e246eb317c31d3f5a7dd3816d012930e5 Mon Sep 17 00:00:00 2001 From: msjk27 Date: Sun, 29 Oct 2023 10:03:10 +0000 Subject: [PATCH 1/2] added tweets_crawling --- modules/crawling/tweets_crawling.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/crawling/tweets_crawling.py b/modules/crawling/tweets_crawling.py index 8b13789..ec6557c 100644 --- a/modules/crawling/tweets_crawling.py +++ b/modules/crawling/tweets_crawling.py @@ -1 +1,14 @@ +import tweepy +# 트위터 개발자 계정에서 얻은 키들을 아래에 입력하세요. +def tweets_crawling(consumer_key, consumer_secret, access_token, access_token_secret, keyword): + auth = tweepy.OAuthHandler(consumer_key, consumer_secret) + auth.set_access_token(access_token, access_token_secret) + + api = tweepy.API(auth) + + # 특정 키워드가 포함된 트윗을 검색합니다. + public_tweets = api.search(q=keyword, lang="ko", count=5) + + for tweet in public_tweets: + print(tweet.text) From 1d846523240c42500e42f278b26c6fe7443c7b30 Mon Sep 17 00:00:00 2001 From: msjk27 Date: Sun, 29 Oct 2023 10:07:48 +0000 Subject: [PATCH 2/2] feat: changed tweets_crawling) --- modules/crawling/tweets_crawling.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/crawling/tweets_crawling.py b/modules/crawling/tweets_crawling.py index ec6557c..db46ada 100644 --- a/modules/crawling/tweets_crawling.py +++ b/modules/crawling/tweets_crawling.py @@ -10,5 +10,4 @@ def tweets_crawling(consumer_key, consumer_secret, access_token, access_token_se # 특정 키워드가 포함된 트윗을 검색합니다. public_tweets = api.search(q=keyword, lang="ko", count=5) - for tweet in public_tweets: - print(tweet.text) + return public_tweets