使用するPythonのライブラリは、
Pandas : 最早Pythonの定番のデータ構造化用ライブラリです。
NumPy: データの構造を更に加工しやすい用に整理してくれます。
(pandasをインストールするとついてきます。)
tweepy: twitterのデータを簡単に取得できるようにするAPIです。
どれも、pipでインストールできますので、インストールしてください。 又、tweepyを利用する為には、最初にtwitterのdeveloperアカウントを登録して、認証用のコードを取得しておく必要があります。 やり方はネットに沢山書かれてますので。(ちなみに、アカウント承認に数日かかった、という投稿も目にしますが、自分の場合は即時にアカウント承認されました。 色々ですね。)
1. tweepyでTwitterのデータにアクセスする為の基本
次の2つのpyファイルを作って、同じフォルダに入れる。
credential.py
CONSUMER_KEY = ' 自分のコードを書いてください '
CONSUMER_SECRET = ' 自分のコードを書いてください '
# Access:
ACCESS_TOKEN = ' 自分のコードを書いてください '
ACCESS_SECRET = ' 自分のコードを書いてください '
CONSUMER_SECRET = ' 自分のコードを書いてください '
# Access:
ACCESS_TOKEN = ' 自分のコードを書いてください '
ACCESS_SECRET = ' 自分のコードを書いてください '
app.py
import tweepy
import pandas as pd
import numpy as np
from credentials import * # This will allow us to use the keys as variables
# API's setup:
def twitter_setup():
"""
Twitter's API set up with our access keys provided.
"""
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
api = tweepy.API(auth)
return api
extractor = twitter_setup()
tweets = extractor.user_timeline(screen_name="realDonaldTrump", count=30)
♯取得したデータの処理
♯ ① 取得したtweetの個数表示
print("Number of tweets extracted: {}.\n".format(len(tweets)))
♯ ② 取得したtweetのtext表示
for tweet in tweets[:15]:
print(tweet.text)
print()
import pandas as pd
import numpy as np
from credentials import * # This will allow us to use the keys as variables
# API's setup:
def twitter_setup():
"""
Twitter's API set up with our access keys provided.
"""
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
api = tweepy.API(auth)
return api
extractor = twitter_setup()
tweets = extractor.user_timeline(screen_name="realDonaldTrump", count=30)
♯取得したデータの処理
♯ ① 取得したtweetの個数表示
print("Number of tweets extracted: {}.\n".format(len(tweets)))
♯ ② 取得したtweetのtext表示
for tweet in tweets[:15]:
print(tweet.text)
print()
ちょっと解説)
API Setup : 色々書き方がありますが、これが一番、直接的でわかりやすいです。
user_timeline() : tweepyでデータを取得するメソッドです。 最新の20個のデータを取得できます。
API.home_timeline([since_id][, max_id][, count][, page])
が文法になります。(http://docs.tweepy.org/en/3.7.0/api.html)
このapp.pyを実行すると、
*自分のPCはwindowsなので、コマンドラインから、(venv)を起動してapp.pyを実行しています。
venvの構築は、こちらの記事に。
#Output①
Number of tweets extracted: 30.
(取得するtweetにデータ形式エラーのものがあると、途中で処理が終わってしまうそうです。 これは別途対応します。)
#Output②
The Great State of Tennessee is so close to passing School Choice. All of our Na
tion’s children, regardless of back… https://t.co/waTxCBpsMD
.@SenMikeLee of the great state of Utah has written a wonderful new book entitle
d, “Our Lost Declaration.” Highly recommended!
As ONE UNITED NATION, we will work, we will pray, and we will fight for the day
when every family across our land c… https://t.co/IcjJfEnaE1
Today, @FLOTUS Melania and I were honored to join thousands of leaders from acro
ss the Country for the 2019 Prescri… https://t.co/t9bRwNnIy9
これは、tweepyで取得されたオブジェクトの中で、text属性を指定して表示したものです。
さて、この.text属性のデータの他にも、多くの属性データが取得されています。
このuser_timeline()で取得したObjectのタイプは、
>>> type(tweets)
<class 'tweepy.models.ResultSet'>
https://stackoverflow.com/questions/42542327/how-to-extract-information-from-tweepy-resultset
'tweepy.models.ResultSet'は、リスト形式のiterableなデータです。
tweetsに格納された全データの取得
>>> print(tweets[0])
Status(_api=<tweepy.api.API object at 0x0000000007552278>, _json={'created_at': 'Fri Apr 26 22:
57:34 +0000 2019', 'id': 1121911223212285953, 'id_str': '1121911223212285953', 'text': 'THANK Y
OU @NRA! #NRAAM https://t.co/SWkpe1eFhT', 'truncated': False, 'entities': {'hashtags': [{'text'
: 'NRAAM', 'indices': [16, 22]}], 'symbols': [], 'user_mentions': [{'screen_name': 'NRA', 'name
': 'NRA', 'id': 21829541, 'id_str': '21829541', 'indices': [10, 14]}], 'urls': [], 'media': [{'
…果てしなく続くので以下省略
>>> type(tweets[0])
<class 'tweepy.models.Status'>
格納されているデータをDictionary形式に変換
>>> tweets[0] .__dict__
{'_api': <tweepy.api.API object at 0x0000000007552278>, '_json': {'created_at': 'Fri Apr 26 22:
57:34 +0000 2019', 'id': 1121911223212285953, 'id_str': '1121911223212285953', 'text': 'THANK Y
OU @NRA! #NRAAM https://t.co/SWkpe1eFhT', 'truncated': False, 'entities': {'hashtags': [{'text'
: 'NRAAM', 'indices': [16, 22]}], 'symbols': [], 'user_mentions': [{'screen_name': 'NRA', 'name
…果てしなく続くので以下省略
DictionaryデータのKeyを取得
>>> tweets[0] .__dict__ .keys()
dict_keys(['_api', '_json', 'created_at', 'id', 'id_str', 'text', 'truncated', 'entities', 'extended_entities', 'source', 'source_url', 'in_reply_to_status_id', 'in_reply_to_status_id_str','in_reply_to_user_id', 'in_reply_to_user_id_str', 'in_reply_to_screen_name', 'author', 'user','geo', 'coordinates', 'place', 'contributors', 'is_quote_status', 'retweet_count', 'favorite_count', 'favorited', 'retweeted', 'possibly_sensitive', 'lang'])
又は
>>>print(dir(tweets[0]))
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_api', '_json', 'author', 'contributors', 'coordinates', 'created_at', 'destroy', 'entities', 'favorite', 'favorite_count', 'favorited', 'geo', 'id', 'id_str', 'in_reply_to_screen_name', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'in_reply_to_user_id', 'in_reply_to_user_id_str', 'is_quote_status', 'lang', 'parse', 'parse_list', 'place', 'retweet', 'retweet_count', 'retweeted', 'retweets', 'source', 'source_url', 'text', 'truncated', 'user']
そこで、これらの属性を指定して値を取得してみます。
print(tweets[0].favorite_count)
76742
print(tweets[0].retweet_count)
18597
2. Pandasで取得したデータ構造を整理する
1) pandasのDataFrameを使って、表を作成します。
app.pyに以下の記述を追加。
data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['Tweets'])
print(data)
print(data)
Output
Tweets
0 The Great State of Tennessee is so close to pa...
1 .@SenMikeLee of the great state of Utah has wr...
2 As ONE UNITED NATION, we will work, we will pr...
3 Today, @FLOTUS Melania and I were honored to j...
4 Rep. Alexandria Ocasio-Cortez is correct, the ...
5 I didn’t call Bob Costa of the Washington Post...
6 ....Congress has no time to legislate, they on...
7 No Collusion, No Obstruction - there has NEVER...
8 Can anyone comprehend what a GREAT job Border ...
・・・30個続いていますが省略
左の数字はindex.
2) Columnの追加
(参考:https://www.tutorialspoint.com/python_pandas/python_pandas_introduction.htm)
app.py
data['len'] = np.array([len(tweet.text) for tweet in tweets])
data['ID'] = np.array([tweet.id for tweet in tweets])
data['Date'] = np.array([tweet.created_at for tweet in tweets])
data['Source'] = np.array([tweet.source for tweet in tweets])
data['Likes'] = np.array([tweet.favorite_count for tweet in tweets])
data['RTs'] = np.array([tweet.retweet_count for tweet in tweets])
print(data)
Output
Tweets len ... Likes RTs
0 The Great State of Tennessee is so close to pa... 140 ... 77992 18832
1 .@SenMikeLee of the great state of Utah has wr... 126 ... 47258 11420
2 As ONE UNITED NATION, we will work, we will pr... 140 ... 60408 14881
Columnが追加されています。
色々とできそうです。
3)Columnの削除
data.drop(columns=['Likes','RTs'],inplace=True)
***** DataFrameの取り扱い (DataFrame.values )*****
# importing pandas as pd
import
pandas as pd
# Creating the DataFrame
df
=
pd.DataFrame({
"A"
:[
12
,
4
,
5
,
None
,
1
],
"B"
:[
7
,
2
,
54
,
3
,
None
],
"C"
:[
20
,
16
,
11
,
3
,
8
],
"D"
:[
14
,
3
,
None
,
2
,
6
]})
# Print the DataFrame
print
(df)
Output
Weight Name Age
0 45 Sam 14
1 88 Andrea 25
2 56 Alex 55
3 15 Robin 8
4 71 Kia 21
print(df.values)
Output
[[45 'Sam' 14]
[88 'Andrea' 25]
[56 'Alex' 55]
[15 'Robin' 8]
[71 'Kia' 21]]
print(df.values[0])
[45 'Sam' 14]
print(df.values[0][1])
Sam
◇pandas dataframeに格納されたデータのタイプ
print(df.dtypes)
Date datetime64[ns]
ID int64
Like int64
Tweet object
Date2 object
dtype: object
(参考)
https://www.geeksforgeeks.org/python-pandas-dataframe-values/
最終的なまとめ
app.py
import tweepy # To consume Twitter's API
import pandas as pd # To handle data
import numpy as np # For number computing
# We import our access keys:
from credentials import * # This will allow us to use the keys as variables
# API's setup:
def twitter_setup():
"""
Utility function to setup the Twitter's API
with our access keys provided.
"""
# Authentication and access using keys:
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
# Return API with authentication:
api = tweepy.API(auth)
return api
# We create an extractor object:
extractor = twitter_setup()
# We create a tweet list as follows:
tweets = extractor.user_timeline(screen_name="realDonaldTrump", count=30)
print("Number of tweets extracted: {}.\n".format(len(tweets)))
for tweet in tweets[:30]:
print(tweet.text)
print()
#Creating a (pandas) DataFrame
data = pd.DataFrame(data=[tweet.text for tweet in tweets], columns=['Tweets'])
print(data)
print(data.head(10))
print(data.tail(10))
print(dir(tweets[0]))
print(tweets[0].favorite_count)
print(tweets[0].retweet_count)
data['len'] = np.array([len(tweet.text) for tweet in tweets])
data['ID'] = np.array([tweet.id for tweet in tweets])
data['Date'] = np.array([tweet.created_at for tweet in tweets])
data['Source'] = np.array([tweet.source for tweet in tweets])
data['Likes'] = np.array([tweet.favorite_count for tweet in tweets])
data['RTs'] = np.array([tweet.retweet_count for tweet in tweets])
print(data)
# We extract the tweet with more FAVs and more RTs:
fav_max = np.max(data['Likes'])
rt_max = np.max(data['RTs'])
fav = data[data.Likes == fav_max].index[0]
rt = data[data.RTs == rt_max].index[0]
# Max FAVs:
print("The tweet with more likes is: \n{}".format(data['Tweets'][fav]))
print("Number of likes: {}".format(fav_max))
print("{} characters.\n".format(data['len'][fav]))
# Max RTs:
print("The tweet with more retweets is: \n{}".format(data['Tweets'][rt]))
print("Number of retweets: {}".format(rt_max))
print("{} characters.\n".format(data['len'][rt]))
(output)
Number of tweets extracted: 30.
The Great State of Tennessee is so close to passing School Choice. All of our Na
tion’s children, regardless of back… https://t.co/waTxCBpsMD
.@SenMikeLee of the great state of Utah has written a wonderful new book entitle
d, “Our Lost Declaration.” Highly recommended!
As ONE UNITED NATION, we will work, we will pray, and we will fight for the day
when every family across our land c… https://t.co/IcjJfEnaE1
Today, @FLOTUS Melania and I were honored to join thousands of leaders from acro
ss the Country for the 2019 Prescri… https://t.co/t9bRwNnIy9
Rep. Alexandria Ocasio-Cortez is correct, the VA is not broken, it is doing grea
t. But that is only because of the… https://t.co/2XHTS0gNl9
I didn’t call Bob Costa of the Washington Post, he called me (Returned his call
)! Just more Fake News.
....Congress has no time to legislate, they only want to continue the Witch Hunt
, which I have already won. They sh… https://t.co/SR99p1tb72
No Collusion, No Obstruction - there has NEVER been a President who has been mor
e transparent. Millions of pages of… https://t.co/v8HpsttkC5
Can anyone comprehend what a GREAT job Border Patrol and Law Enforcement is doin
g on our Southern Border. So far th… https://t.co/G13GJJCTeV
.....are there no “High Crimes and Misdemeanors,” there are no Crimes by me at
all. All of the Crimes were committe… https://t.co/CfcpFiyym7
The Mueller Report, despite being written by Angry Democrats and Trump Haters, a
nd with unlimited money behind it (… https://t.co/P0Xq2h0Boq
Mexico’s Soldiers recently pulled guns on our National Guard Soldiers, probably
as a diversionary tactic for drug s… https://t.co/bpPOy93S7x
A very big Caravan of over 20,000 people started up through Mexico. It has been
reduced in size by Mexico but is st… https://t.co/xoErbSRTwA
The American people deserve to know who is in this Country. Yesterday, the Supre
me Court took up the Census Citizen… https://t.co/xrFCfBHsXj
“Former CIA analyst Larry Johnson accuses United Kingdom Intelligence of helpin
g Obama Administration Spy on the 20… https://t.co/ShzvQun68s
Thanks Rush! @FoxNews https://t.co/x8XogwA8VX
You mean the Stock Market hit an all-time record high today and they’re actuall
y talking impeachment!? Will I ever… https://t.co/Z8CfnRuMy7
Great meeting this afternoon at the @WhiteHouse with @Jack from @Twitter. Lots o
f subjects discussed regarding thei… https://t.co/Sw2ZwrclUT
I will be in Green Bay, Wisconsin this Saturday, April 27th at the Resch Center
— 7:00pm (CDT). Big crowd expected!… https://t.co/4O8qSG4CYp
Great golf champion & friend, Ernie Els (@TheBig_Easy), has done a tremendou
s job in assisting those w/ Autism thro… https://t.co/RimZI6BXKC
Great interview by Jared. Nice to have extraordinarily smart people serving our
Country! https://t.co/d6Tgrn4Tzn
KEEP AMERICA GREAT!
The Wall is being rapidly built! The Economy is GREAT! Our Country is Respected
again!
.....But should be much higher than that if Twitter wasn’t playing their politi
cal games. No wonder Congress wants… https://t.co/e1I3vgV1Ug
“The best thing ever to happen to Twitter is Donald Trump.” @MariaBartiromo S
o true, but they don’t treat me well… https://t.co/5jwDvocFqG
“Harley Davidson has struggled with Tariffs with the EU, currently paying 31%.
They’ve had to move production overs… https://t.co/r0RAX6jBHU
....Dumb and Sick. A really bad show with low ratings - and will only get worse.
CNN has been a proven and long ter… https://t.co/owlRr5I3P6
Sorry to say but @foxandfriends is by far the best of the morning political show
s on television. It rightfully has… https://t.co/SpyApUgKBK
In the “old days” if you were President and you had a good economy, you were b
asically immune from criticism. Remem… https://t.co/lRBKqFnFle
The Radical Left Democrats, together with their leaders in the Fake News Media,
have gone totally insane! I guess t… https://t.co/m87QJerN6a
Tweets
0 The Great State of Tennessee is so close to pa...
1 .@SenMikeLee of the great state of Utah has wr...
2 As ONE UNITED NATION, we will work, we will pr...
3 Today, @FLOTUS Melania and I were honored to j...
4 Rep. Alexandria Ocasio-Cortez is correct, the ...
5 I didn’t call Bob Costa of the Washington Post...
6 ....Congress has no time to legislate, they on...
7 No Collusion, No Obstruction - there has NEVER...
8 Can anyone comprehend what a GREAT job Border ...
9 .....are there no “High Crimes and Misdemeanor...
10 The Mueller Report, despite being written by A...
11 Mexico’s Soldiers recently pulled guns on our ...
12 A very big Caravan of over 20,000 people start...
13 The American people deserve to know who is in ...
14 “Former CIA analyst Larry Johnson accuses Unit...
15 Thanks Rush! @FoxNews https://t.co/x8XogwA8VX
16 You mean the Stock Market hit an all-time reco...
17 Great meeting this afternoon at the @WhiteHous...
18 I will be in Green Bay, Wisconsin this Saturda...
19 Great golf champion & friend, Ernie Els (@...
20 Great interview by Jared. Nice to have extraor...
21 KEEP AMERICA GREAT!
22 The Wall is being rapidly built! The Economy i...
23 .....But should be much higher than that if Tw...
24 “The best thing ever to happen to Twitter is D...
25 “Harley Davidson has struggled with Tariffs wi...
26 ....Dumb and Sick. A really bad show with low ...
27 Sorry to say but @foxandfriends is by far the ...
28 In the “old days” if you were President and yo...
29 The Radical Left Democrats, together with thei...
Tweets
0 The Great State of Tennessee is so close to pa...
1 .@SenMikeLee of the great state of Utah has wr...
2 As ONE UNITED NATION, we will work, we will pr...
3 Today, @FLOTUS Melania and I were honored to j...
4 Rep. Alexandria Ocasio-Cortez is correct, the ...
5 I didn’t call Bob Costa of the Washington Post...
6 ....Congress has no time to legislate, they on...
7 No Collusion, No Obstruction - there has NEVER...
8 Can anyone comprehend what a GREAT job Border ...
9 .....are there no “High Crimes and Misdemeanor...
Tweets
0 The Great State of Tennessee is so close to pa...
1 .@SenMikeLee of the great state of Utah has wr...
2 As ONE UNITED NATION, we will work, we will pr...
3 Today, @FLOTUS Melania and I were honored to j...
4 Rep. Alexandria Ocasio-Cortez is correct, the ...
5 I didn’t call Bob Costa of the Washington Post...
6 ....Congress has no time to legislate, they on...
7 No Collusion, No Obstruction - there has NEVER...
8 Can anyone comprehend what a GREAT job Border ...
9 .....are there no “High Crimes and Misdemeanor...
Tweets
20 Great interview by Jared. Nice to have extraor...
21 KEEP AMERICA GREAT!
22 The Wall is being rapidly built! The Economy i...
23 .....But should be much higher than that if Tw...
24 “The best thing ever to happen to Twitter is D...
25 “Harley Davidson has struggled with Tariffs wi...
26 ....Dumb and Sick. A really bad show with low ...
27 Sorry to say but @foxandfriends is by far the ...
28 In the “old days” if you were President and yo...
29 The Radical Left Democrats, together with thei...
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__form
at__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__in
it__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__
', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__st
r__', '__subclasshook__', '__weakref__', '_api', '_json', 'author', 'contributor
s', 'coordinates', 'created_at', 'destroy', 'entities', 'favorite', 'favorite_co
unt', 'favorited', 'geo', 'id', 'id_str', 'in_reply_to_screen_name', 'in_reply_t
o_status_id', 'in_reply_to_status_id_str', 'in_reply_to_user_id', 'in_reply_to_u
ser_id_str', 'is_quote_status', 'lang', 'parse', 'parse_list', 'place', 'retweet
', 'retweet_count', 'retweeted', 'retweets', 'source', 'source_url', 'text', 'tr
uncated', 'user']
77992
18832
Tweets len ... Likes RTs
0 The Great State of Tennessee is so close to pa... 140 ... 77992 18832
1 .@SenMikeLee of the great state of Utah has wr... 126 ... 47258 11420
2 As ONE UNITED NATION, we will work, we will pr... 140 ... 60408 14881
3 Today, @FLOTUS Melania and I were honored to j... 140 ... 45652 11040
4 Rep. Alexandria Ocasio-Cortez is correct, the ... 139 ... 81781 18455
5 I didn’t call Bob Costa of the Washington Post... 103 ... 70328 15617
6 ....Congress has no time to legislate, they on... 140 ... 109192 27222
7 No Collusion, No Obstruction - there has NEVER... 140 ... 91252 21448
8 Can anyone comprehend what a GREAT job Border ... 140 ... 81792 19334
9 .....are there no “High Crimes and Misdemeanor... 140 ... 75596 20328
10 The Mueller Report, despite being written by A... 140 ... 92288 22773
11 Mexico’s Soldiers recently pulled guns on our ... 140 ... 117837 31477
12 A very big Caravan of over 20,000 people start... 140 ... 81865 22350
13 The American people deserve to know who is in ... 140 ... 117294 26245
14 “Former CIA analyst Larry Johnson accuses Unit... 140 ... 99288 32467
15 Thanks Rush! @FoxNews https://t.co/x8XogwA8VX 45 ... 83279 25392
16 You mean the Stock Market hit an all-time reco... 139 ... 147051 34128
17 Great meeting this afternoon at the @WhiteHous... 140 ... 72291 19238
18 I will be in Green Bay, Wisconsin this Saturda... 140 ... 58720 15744
19 Great golf champion & friend, Ernie Els (@... 144 ... 67200 14309
20 Great interview by Jared. Nice to have extraor... 112 ... 59134 13678
21 KEEP AMERICA GREAT! 19 ... 161004 31272
22 The Wall is being rapidly built! The Economy i... 86 ... 141458 27744
23 .....But should be much higher than that if Tw... 139 ... 70032 16713
24 “The best thing ever to happen to Twitter is D... 139 ... 83959 20241
25 “Harley Davidson has struggled with Tariffs wi... 140 ... 68667 16352
26 ....Dumb and Sick. A really bad show with low ... 140 ... 76628 16914
27 Sorry to say but @foxandfriends is by far the ... 139 ... 75825 17264
28 In the “old days” if you were President and yo... 140 ... 149719 31420
29 The Radical Left Democrats, together with thei... 140 ... 68631 16774
[30 rows x 7 columns]
The tweet with more likes is:
KEEP AMERICA GREAT!
Number of likes: 161004
19 characters.
The tweet with more retweets is:
You mean the Stock Market hit an all-time record high today and they’re actuall
y talking impeachment!? Will I ever… https://t.co/Z8CfnRuMy7
Number of retweets: 34128
139 characters.
◇ user_timeline()で取得できるValueの確認
tweets = extractor.user_timeline(screen_name="realDonaldTrump", count=30)
>>> type(tweets)
<class 'tweepy.models.ResultSet'>
'author', 'contributors', 'coordinates', 'created_at', 'destroy', 'entities', 'favorite', 'favorite_count', 'favorited', 'geo', 'id', 'id_str', 'in_reply_to_screen_name', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'in_reply_to_user_id', 'in_reply_to_user_id_str', 'is_quote_status', 'lang', 'parse', 'parse_list', 'place', 'retweet', 'retweet_count', 'retweeted', 'retweets', 'source', 'source_url', 'text', 'truncated', 'user']
◇ author0 User(_api=<tweepy.api.API object at 0x00000000...
1 User(_api=<tweepy.api.API object at 0x00000000...
2 User(_api=<tweepy.api.API object at 0x00000000...
◇ created_at
0 2019-04-30 01:23:49
1 2019-04-30 01:17:20
◇ entities
0 {'hashtags': [], 'symbols': [], 'user_mentions...
1 {'hashtags': [], 'symbols': [], 'user_mentions...
◇favorite
0 <bound method Status.favorite of Status(_api=<...
1 <bound method Status.favorite of Status(_api=<...
2 <bound method Status.favorite of Status(_api=<...
◇favorite_count
0 60111
1 50856
2 50803
◇id
0 1123035192262823936
1 1123033559802023936
2 1123002475601170433
◇user
0 User(_api=<tweepy.api.API object at 0x00000000...
1 User(_api=<tweepy.api.API object at 0x00000000...
2 User(_api=<tweepy.api.API object at 0x00000000...
◇ Cusror()でKey Wordを指定して、(且つ条件付きで) Tweetを取得する。
query ="Rugby World Cup"
count =10
tweets = tw.Cursor(api.search, q="Rugby World Cup min_faves:10 min_retweets:5 exclude:retweets",result_type="recent", include_entities="True",tweet_mode="extended", lang="en").items(count)
0 件のコメント:
コメントを投稿