リツイートデータへのアクセス
今度は、リツイートを含むツイートの JSON を扱います。リツイートは通常のツイートと同じ構造をしていますが、retweeted_status に別のツイートが格納されている点が異なります。
この新しいツイートは rt として読み込まれています。
この演習はコースの一部です
Python でのソーシャルメディアデータ分析
演習の手順
- ツイートのテキストを出力しましょう。
retweeted_statusに含まれる、リツイートされたツイートのテキストを出力しましょう。- ツイートのユーザーハンドルを出力しましょう。
retweeted_statusに含まれる、リツイートされたツイートのユーザーハンドルを出力しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Print the text of the tweet
print(rt[____])
# Print the text of tweet which has been retweeted
print(rt[____][____])
# Print the user handle of the tweet
print(rt[____][____])
# Print the user handle of the tweet which has been retweeted
print(rt[____][____][____])