LoginSignup
2
5

More than 1 year has passed since last update.

Instagramから情報を取得してみた(Python)

Last updated at Posted at 2022-07-10

はじめに

Instagramから情報取得するInstaloderというライブラリを発見したので
Pythonで簡単なユーザ情報を取得してみました

Instaloderについて

Instaloaderは、写真(またはビデオ)とそのキャプションおよびその他のメタデータをInstagramからダウンロードするためのツールです。(下記サイトより引用)

環境構築

下記コマンドを実行

pip3 install instaloader

Instagramから情報を取得手順

今回はTwiceのモモさんの情報を取得してこようと思います
Twiceは最近知りました汗

get_instagram.py
import profile
from instaloader import instaloader, Profile

# Instaloaderインスタンス作成
IL = instaloader.Instaloader()

id = 'momo' # モモさんのInstagramアカウントID
profile = Profile.from_username(IL.context, id)
# ユーザ名
username = profile.full_name
# 投稿数
posts = profile.mediacount
# フォロワー数
follewer = profile.followers
# フォロー数
follow = profile.followees

# 出力
print(f'ユーザー名:{username}\n投稿数:{posts}\nフォロワー数:{follewer}\nフォロー数:{follow}')

出力結果

python3 get_instagram.py 

>ユーザー名:모모 (MOMO)
投稿数:19
フォロワー数:6986352
フォロー数:0

次は投稿された画像も取得してみようと思います

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5