Skip to content

Instantly share code, notes, and snippets.

@nagishin
Created December 6, 2021 02:34
Show Gist options
  • Save nagishin/328bcc566e28924e700fc99f02130f18 to your computer and use it in GitHub Desktop.
Save nagishin/328bcc566e28924e700fc99f02130f18 to your computer and use it in GitHub Desktop.
twitter_reserch.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "twitter_reserch.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyONOnG5/mAh2XDNVt9ItrAC",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/nagishin/328bcc566e28924e700fc99f02130f18/twitter_reserch.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "ie0nUhBYUYet"
},
"source": [
"!pip install tweepy"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "bvRhsD7yUXYO"
},
"source": [
"# coding: -*- utf-8 -*-\n",
"import numpy as np\n",
"import pandas as pd\n",
"import tweepy\n",
"import pprint\n",
"from datetime import datetime, timezone, timedelta\n",
"import pytz\n",
"from pprint import pprint\n",
"\n",
"# Twitter API Key/Token設定\n",
"consumer_key = ''\n",
"consumer_secret = ''\n",
"access_token = ''\n",
"access_token_secret = ''\n",
"\n",
"# tweepy APIインスタンス生成\n",
"auth = tweepy.OAuthHandler(consumer_key, consumer_secret)\n",
"auth.set_access_token(access_token, access_token_secret)\n",
"api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)\n",
"\n",
"# アクティブユーザ判定期間\n",
"ACTIVE_LIMIT_DAYS = 30"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "6rHoPFIPOI0y",
"outputId": "d8d936a0-e441-4968-a411-980e6f625b38"
},
"source": [
"# 対象ユーザーリスト\n",
"df = pd.read_csv('botters.csv')\n",
"IDs = df.ID.values\n",
"print(IDs)"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"['sen_axis' 'azuma_bitcoin' 'blog_uki' 'CRYPTANNEWS' 'i_love_profit'\n",
" 'project_bbb' 'tomui_bitcoin' 'Crypto_Rid' 'watacchikasou' '6G_bitflyer'\n",
" 'boocham_bot' 'snufkin0866' 'kasou365' 'poyothon' 'tradenist'\n",
" 'cryptrader2020' 'mebi_trade' 'supermomonga' 'yasu_smaholi' 'moycoin'\n",
" 'horumonR_fx' 'Ros_1224' 'One619hebotter' 'kunmosky1' 'bitcoinseeker'\n",
" 'shidokamo' 'satonaka_jp' 'albaman001' 'regolith1223' 'mnt_coins'\n",
" 'jitekineko' 'Nagi7692' 'SoftgateJa' 'javeleeer' 'richmanbtc2' 'kuchanFX'\n",
" 'SAPI_tokyo' 'furatocoin' 'furureba' 'AmadoTanzirou' 'QuantsMan'\n",
" 'okachan_nem' 'muzineco' '0xlqfc' 'kieli0605' 'jacko225m' '_P_E_N_T_A'\n",
" 'ballsan8' 'mazmex7' 'arms22' 'ren__1213' 'cryptoo_bear' 'rc_uni0907'\n",
" 'dosu0217' 'ArbitrageTigers' 'MtkN1XBt' 'Seville1985' 'kasousekai2'\n",
" 'dddatacrazy' 'Freeza_BtcBot' 'dakuruto' 'reo3313' 'actu3' 'EwanBotter'\n",
" 'CKadumin' 'kijitora_2018' 'matcha_btc' 'amdapsi' 'sakechi_btc'\n",
" 'iitarrore' 'CcYuza' 'shinjiro_tigers' 'iNaGoBotTrader' '_numbP'\n",
" 'zephel01_vc' 'd2ftaxi' 'geboneko' 'algon_fx' 'ez_botter' 'take_btc'\n",
" 'OkaneNoNioi' 'CryptoNinjaX' '_and_go' 'npp_crypto' 'hihihihi1986'\n",
" 'hami__cc' 'tradetomato' 'ryu_botter' 'trading_algo_Q' 'tit_BTCQASH'\n",
" 'nipperjapan' 'yutas001' 'phantom_smf' 'yui_bitcoin' 'asahinoboru_jp'\n",
" 'jassie0406' 'will_botter' 'Warashibe2020' 'kk1110tt' 'de_no_hito'\n",
" 'Nickel_Mekki' 'ryuta461' 'MJ24_trader' 'piyopiyotch' 'xxgreedx'\n",
" 'cryptoJUN' 'momo_cryptoc' 'syasyasyasyathx' 'him0net' 'brokenthemoon'\n",
" 'kapipara180' 'ahaha_fxtrader' 'SiroNegio' 'yuu_kun00' 'takiyamamama'\n",
" 'j262226' '_moro_hey_yeah' 'JapaneseMl' '_void_warrior' 'tadajam'\n",
" 'boufuu' 'tibita78' 'misanfx']\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "3-gfegON5TVA"
},
"source": [
"# 直近limit_daysのツイート取得\n",
"def get_tweets(api, id, limit_days=7):\n",
" try:\n",
" ret = {\n",
" 'tweet': [],\n",
" 'retweet': [],\n",
" 'quote': [],\n",
" 'reply': [],\n",
" }\n",
" limit_date = datetime.now(timezone(timedelta(hours=+9), 'JST')) - timedelta(days=limit_days)\n",
" tweets = tweepy.Cursor(api.user_timeline, id=id, cursor=-1, count=200).items()\n",
" for tweet in tweets:\n",
" utc_dt = pytz.utc.localize(tweet.created_at)\n",
" cur_jst_dt = utc_dt.astimezone(pytz.timezone('Asia/Tokyo'))\n",
" if cur_jst_dt < limit_date:\n",
" break\n",
" info = {\n",
" 'created': cur_jst_dt,\n",
" 'retweets': tweet.retweet_count,\n",
" 'likes': tweet.favorite_count,\n",
" }\n",
" if tweet.in_reply_to_status_id is not None:\n",
" ret['reply'].append(info)\n",
" elif 'RT @' in tweet.text:\n",
" ret['retweet'].append(info)\n",
" elif tweet.is_quote_status:\n",
" ret['quote'].append(info)\n",
" else:\n",
" ret['tweet'].append(info)\n",
"\n",
" except tweepy.error.TweepError as e:\n",
" if e is None or e.response is None:\n",
" print(f'[get_tweets TweepError] Unknown (id: {id})')\n",
" else:\n",
" print(f'[get_tweets TweepError] {e.response.reason} (id: {id})')\n",
" except Exception as e:\n",
" print(f'[get_tweets Exception] {e} (id: {id})')\n",
"\n",
" return ret"
],
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "q18YcOFzjLJB"
},
"source": [
"# 対象ユーザのアカウント情報取得\n",
"def get_user_info(api, id, is_simple=False):\n",
" get_tweet_days = 7\n",
" user_info = {\n",
" 'id': id,\n",
" 'screen_name': '',\n",
" 'name': '',\n",
" 'protected': False,\n",
" 'followers': 0,\n",
" 'friends': 0,\n",
" 'user_created': None,\n",
" 'updated': None,\n",
" 'status': 'error',\n",
" 'total_likes': 0,\n",
" 'total_tweets': 0,\n",
" 'week_tweets': 0,\n",
" 'avr_day_tweets': 0.0,\n",
" 'week_retweets': 0,\n",
" 'avr_day_retweets': 0.0,\n",
" 'week_quotes': 0,\n",
" 'avr_day_quotes': 0.0,\n",
" 'week_replies': 0,\n",
" 'avr_day_replies': 0.0,\n",
" 'week_tweets_get_retweets': 0,\n",
" 'avr_get_retweets': 0.0,\n",
" 'week_tweets_get_likes': 0,\n",
" 'avr_get_likes': 0.0,\n",
" }\n",
"\n",
" try:\n",
" user = api.get_user(id)\n",
"\n",
" user_info['id'] = user.id_str\n",
" user_info['screen_name'] = user.screen_name\n",
" user_info['name'] = user.name\n",
" user_info['protected'] = user.protected\n",
" user_info['followers'] = user.followers_count\n",
" user_info['friends'] = user.friends_count\n",
" user_info['total_likes'] = user.favourites_count\n",
" user_info['total_tweets'] = user.statuses_count\n",
" utc_created = pytz.utc.localize(user.created_at)\n",
" user_info['user_created'] = utc_created.astimezone(pytz.timezone('Asia/Tokyo'))\n",
"\n",
" tweets = None\n",
" favorites = None\n",
" if is_simple == False:\n",
" if user.favourites_count > 0:\n",
" favorites = api.favorites(id=id, count=1)\n",
" tweets = get_tweets(api, id=id, limit_days=get_tweet_days)\n",
" except tweepy.error.TweepError as e:\n",
" if e is None or e.response is None:\n",
" print(f'[get_user_info TweepError] Unknown (id: {id})')\n",
" else:\n",
" print(f'[get_user_info TweepError] {e.response.reason} (id: {id})')\n",
" return user_info\n",
"\n",
" try:\n",
" jst_last = None\n",
" if user.statuses_count > 0:\n",
" utc_last = pytz.utc.localize(user.status.created_at)\n",
" jst_last = utc_last.astimezone(pytz.timezone('Asia/Tokyo'))\n",
"\n",
" jst_liked = None\n",
" if favorites is not None and user.favourites_count > 0:\n",
" for favorite in favorites:\n",
" utc_liked = pytz.utc.localize(favorite.created_at)\n",
" jst_liked = utc_liked.astimezone(pytz.timezone('Asia/Tokyo'))\n",
"\n",
" if jst_last is None:\n",
" if jst_liked is None:\n",
" updated = user_info['user_created']\n",
" else:\n",
" updated = jst_liked\n",
" else:\n",
" if jst_liked is None:\n",
" updated = jst_last\n",
" else:\n",
" updated = jst_last if jst_last > jst_liked else jst_liked\n",
"\n",
" limit_date = datetime.now(timezone(timedelta(hours=+9), 'JST')) - timedelta(days=ACTIVE_LIMIT_DAYS)\n",
" status = 'active' if updated >= limit_date else 'inactive'\n",
"\n",
" user_info['updated'] = updated\n",
" user_info['status'] = 'active' if updated >= limit_date else 'inactive'\n",
"\n",
" if tweets is not None:\n",
" user_info['week_tweets'] = len(tweets['tweet'])\n",
" user_info['avr_day_tweets'] = round(float(user_info['week_tweets']) / float(get_tweet_days), 2)\n",
" user_info['week_retweets'] = len(tweets['retweet'])\n",
" user_info['avr_day_retweets'] = round(float(user_info['week_retweets']) / float(get_tweet_days), 2)\n",
" user_info['week_quotes'] = len(tweets['quote'])\n",
" user_info['avr_day_quotes'] = round(float(user_info['week_quotes']) / float(get_tweet_days), 2)\n",
" user_info['week_replies'] = len(tweets['reply'])\n",
" user_info['avr_day_replies'] = round(float(user_info['week_replies']) / float(get_tweet_days), 2)\n",
" user_info['week_tweets_get_retweets'] = sum([t['retweets'] for t in tweets['tweet']])\n",
" user_info['avr_get_retweets'] = round(float(user_info['week_tweets_get_retweets']) / float(user_info['week_tweets']), 2) if user_info['week_tweets'] > 0 else 0\n",
" user_info['week_tweets_get_likes'] = sum([t['likes'] for t in tweets['tweet']])\n",
" user_info['avr_get_likes'] = round(float(user_info['week_tweets_get_likes']) / float(user_info['week_tweets']), 2) if user_info['week_tweets'] > 0 else 0\n",
"\n",
" return user_info\n",
"\n",
" except Exception as e:\n",
" print(f'[get_user_info Exception] {e} (id: {id})')\n",
" return user_info\n"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 671
},
"id": "PmwUh00ynGuw",
"outputId": "58d1ce0b-7b23-4106-ce38-f8ebab07b165"
},
"source": [
"# 対象ユーザの各アカウント情報を取得してリスト化\n",
"lst_user_info = [get_user_info(api, id, is_simple=False) for id in IDs]\n",
"df = pd.DataFrame(lst_user_info)\n",
"df.to_csv('botters_twitter_info.csv', index=False, encoding='utf_8_sig')\n",
"display(df)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[get_user_info TweepError] Unauthorized (id: jitekineko)\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Rate limit reached. Sleeping for: 849\n"
]
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>screen_name</th>\n",
" <th>name</th>\n",
" <th>protected</th>\n",
" <th>followers</th>\n",
" <th>friends</th>\n",
" <th>user_created</th>\n",
" <th>updated</th>\n",
" <th>status</th>\n",
" <th>total_likes</th>\n",
" <th>total_tweets</th>\n",
" <th>week_tweets</th>\n",
" <th>avr_day_tweets</th>\n",
" <th>week_retweets</th>\n",
" <th>avr_day_retweets</th>\n",
" <th>week_quotes</th>\n",
" <th>avr_day_quotes</th>\n",
" <th>week_replies</th>\n",
" <th>avr_day_replies</th>\n",
" <th>week_tweets_get_retweets</th>\n",
" <th>avr_get_retweets</th>\n",
" <th>week_tweets_get_likes</th>\n",
" <th>avr_get_likes</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>738928201162838016</td>\n",
" <td>sen_axis</td>\n",
" <td>ヨーロピアン</td>\n",
" <td>False</td>\n",
" <td>71402</td>\n",
" <td>139</td>\n",
" <td>2016-06-04 11:59:46+09:00</td>\n",
" <td>2021-12-05 19:25:20+09:00</td>\n",
" <td>active</td>\n",
" <td>5435</td>\n",
" <td>17350</td>\n",
" <td>12</td>\n",
" <td>1.71</td>\n",
" <td>1</td>\n",
" <td>0.14</td>\n",
" <td>8</td>\n",
" <td>1.14</td>\n",
" <td>31</td>\n",
" <td>4.43</td>\n",
" <td>130</td>\n",
" <td>10.83</td>\n",
" <td>956</td>\n",
" <td>79.67</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1005316107597635584</td>\n",
" <td>azuma_bitcoin</td>\n",
" <td>あずまっち</td>\n",
" <td>False</td>\n",
" <td>25876</td>\n",
" <td>361</td>\n",
" <td>2018-06-09 14:10:12+09:00</td>\n",
" <td>2021-12-05 17:05:45+09:00</td>\n",
" <td>active</td>\n",
" <td>15983</td>\n",
" <td>3534</td>\n",
" <td>2</td>\n",
" <td>0.29</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>1</td>\n",
" <td>0.14</td>\n",
" <td>4</td>\n",
" <td>0.57</td>\n",
" <td>49</td>\n",
" <td>24.50</td>\n",
" <td>619</td>\n",
" <td>309.50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>810497876648456192</td>\n",
" <td>blog_uki</td>\n",
" <td>UKI</td>\n",
" <td>False</td>\n",
" <td>21541</td>\n",
" <td>408</td>\n",
" <td>2016-12-18 23:52:06+09:00</td>\n",
" <td>2021-12-06 09:23:25+09:00</td>\n",
" <td>active</td>\n",
" <td>13991</td>\n",
" <td>8045</td>\n",
" <td>6</td>\n",
" <td>0.86</td>\n",
" <td>14</td>\n",
" <td>2.00</td>\n",
" <td>8</td>\n",
" <td>1.14</td>\n",
" <td>5</td>\n",
" <td>0.71</td>\n",
" <td>69</td>\n",
" <td>11.50</td>\n",
" <td>535</td>\n",
" <td>89.17</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>930458771347816448</td>\n",
" <td>CRYPTANNEWS</td>\n",
" <td>くりぷます🎄</td>\n",
" <td>True</td>\n",
" <td>19053</td>\n",
" <td>2216</td>\n",
" <td>2017-11-15 00:33:52+09:00</td>\n",
" <td>2021-12-06 10:17:27+09:00</td>\n",
" <td>active</td>\n",
" <td>149019</td>\n",
" <td>74238</td>\n",
" <td>38</td>\n",
" <td>5.43</td>\n",
" <td>8</td>\n",
" <td>1.14</td>\n",
" <td>10</td>\n",
" <td>1.43</td>\n",
" <td>133</td>\n",
" <td>19.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>1830</td>\n",
" <td>48.16</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>930565590166659072</td>\n",
" <td>i_love_profit</td>\n",
" <td>Hoheto</td>\n",
" <td>False</td>\n",
" <td>17917</td>\n",
" <td>197</td>\n",
" <td>2017-11-15 07:38:20+09:00</td>\n",
" <td>2021-12-05 15:58:54+09:00</td>\n",
" <td>active</td>\n",
" <td>10854</td>\n",
" <td>7610</td>\n",
" <td>12</td>\n",
" <td>1.71</td>\n",
" <td>2</td>\n",
" <td>0.29</td>\n",
" <td>6</td>\n",
" <td>0.86</td>\n",
" <td>13</td>\n",
" <td>1.86</td>\n",
" <td>187</td>\n",
" <td>15.58</td>\n",
" <td>1559</td>\n",
" <td>129.92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>118</th>\n",
" <td>1293409688462094336</td>\n",
" <td>_void_warrior</td>\n",
" <td>Void戦士ちゃん</td>\n",
" <td>False</td>\n",
" <td>1057</td>\n",
" <td>104</td>\n",
" <td>2020-08-12 13:52:00+09:00</td>\n",
" <td>2021-12-06 09:41:47+09:00</td>\n",
" <td>active</td>\n",
" <td>1305</td>\n",
" <td>2491</td>\n",
" <td>15</td>\n",
" <td>2.14</td>\n",
" <td>2</td>\n",
" <td>0.29</td>\n",
" <td>2</td>\n",
" <td>0.29</td>\n",
" <td>9</td>\n",
" <td>1.29</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>28</td>\n",
" <td>1.87</td>\n",
" </tr>\n",
" <tr>\n",
" <th>119</th>\n",
" <td>754412944285282304</td>\n",
" <td>tadajam</td>\n",
" <td>tadajam</td>\n",
" <td>False</td>\n",
" <td>1023</td>\n",
" <td>414</td>\n",
" <td>2016-07-17 05:30:37+09:00</td>\n",
" <td>2021-12-05 21:44:36+09:00</td>\n",
" <td>active</td>\n",
" <td>43104</td>\n",
" <td>4114</td>\n",
" <td>9</td>\n",
" <td>1.29</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>1</td>\n",
" <td>0.14</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>6</td>\n",
" <td>0.67</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>10876162</td>\n",
" <td>boufuu</td>\n",
" <td>₿oufuu</td>\n",
" <td>False</td>\n",
" <td>1011</td>\n",
" <td>2686</td>\n",
" <td>2007-12-06 01:58:46+09:00</td>\n",
" <td>2021-11-27 23:42:16+09:00</td>\n",
" <td>active</td>\n",
" <td>13256</td>\n",
" <td>3646</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>971917610622230529</td>\n",
" <td>tibita78</td>\n",
" <td>はぐ@仮想通貨BOT犬</td>\n",
" <td>False</td>\n",
" <td>1007</td>\n",
" <td>290</td>\n",
" <td>2018-03-09 10:16:30+09:00</td>\n",
" <td>2021-12-02 14:40:44+09:00</td>\n",
" <td>active</td>\n",
" <td>500</td>\n",
" <td>1349</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>1</td>\n",
" <td>0.14</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>864926544178761728</td>\n",
" <td>misanfx</td>\n",
" <td>みーさん</td>\n",
" <td>False</td>\n",
" <td>1002</td>\n",
" <td>602</td>\n",
" <td>2017-05-18 04:32:12+09:00</td>\n",
" <td>2021-12-06 09:39:48+09:00</td>\n",
" <td>active</td>\n",
" <td>21046</td>\n",
" <td>18107</td>\n",
" <td>71</td>\n",
" <td>10.14</td>\n",
" <td>9</td>\n",
" <td>1.29</td>\n",
" <td>35</td>\n",
" <td>5.00</td>\n",
" <td>20</td>\n",
" <td>2.86</td>\n",
" <td>8</td>\n",
" <td>0.11</td>\n",
" <td>59</td>\n",
" <td>0.83</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>123 rows × 23 columns</p>\n",
"</div>"
],
"text/plain": [
" id screen_name ... week_tweets_get_likes avr_get_likes\n",
"0 738928201162838016 sen_axis ... 956 79.67\n",
"1 1005316107597635584 azuma_bitcoin ... 619 309.50\n",
"2 810497876648456192 blog_uki ... 535 89.17\n",
"3 930458771347816448 CRYPTANNEWS ... 1830 48.16\n",
"4 930565590166659072 i_love_profit ... 1559 129.92\n",
".. ... ... ... ... ...\n",
"118 1293409688462094336 _void_warrior ... 28 1.87\n",
"119 754412944285282304 tadajam ... 6 0.67\n",
"120 10876162 boufuu ... 0 0.00\n",
"121 971917610622230529 tibita78 ... 0 0.00\n",
"122 864926544178761728 misanfx ... 59 0.83\n",
"\n",
"[123 rows x 23 columns]"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Qh3UcqxfPxYX",
"outputId": "cd835b60-c10c-4c7f-fca4-290812f053f2"
},
"source": [
"# API RateLimit取得\n",
"status = api.rate_limit_status()['resources']\n",
"print(f'API.users {status[\"users\"][\"/users/:id\"]}')\n",
"print(f'API.users.lookup {status[\"users\"][\"/users/lookup\"]}')\n",
"print(f'API.statuses.user_timeline {status[\"statuses\"][\"/statuses/user_timeline\"]}')\n",
"print(f'API.favorites {status[\"favorites\"][\"/favorites/list\"]}')\n",
"print(f'API.followers {status[\"followers\"][\"/followers/list\"]}')\n",
"print(f'API.followers_ids {status[\"followers\"][\"/followers/ids\"]}')\n",
"print(f'API.friends {status[\"friends\"][\"/friends/list\"]}')\n",
"print(f'API.friedns_ids {status[\"friends\"][\"/friends/ids\"]}')\n",
"print(f'API.show_friendship {status[\"friendships\"][\"/friendships/show\"]}')\n",
"print(f'API.search {status[\"search\"][\"/search/tweets\"]}')\n",
"print(f'API.search {status[\"search\"][\"/search/tweets\"]}')\n",
"print(f'API.rate_limit_status {status[\"application\"][\"/application/rate_limit_status\"]}')\n"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"API.users {'limit': 900, 'remaining': 853, 'reset': 1638756085}\n",
"API.users.lookup {'limit': 900, 'remaining': 900, 'reset': 1638756398}\n",
"API.statuses.user_timeline {'limit': 900, 'remaining': 850, 'reset': 1638756085}\n",
"API.favorites {'limit': 75, 'remaining': 27, 'reset': 1638756085}\n",
"API.followers {'limit': 15, 'remaining': 15, 'reset': 1638756398}\n",
"API.followers_ids {'limit': 15, 'remaining': 15, 'reset': 1638756398}\n",
"API.friends {'limit': 15, 'remaining': 15, 'reset': 1638756398}\n",
"API.friedns_ids {'limit': 15, 'remaining': 15, 'reset': 1638756398}\n",
"API.show_friendship {'limit': 180, 'remaining': 180, 'reset': 1638756398}\n",
"API.search {'limit': 180, 'remaining': 180, 'reset': 1638756398}\n",
"API.search {'limit': 180, 'remaining': 180, 'reset': 1638756398}\n",
"API.rate_limit_status {'limit': 180, 'remaining': 180, 'reset': 1638756398}\n"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment