toMedia
快速开始

第一次下载

快速上手 instaloader

🚀 第一次下载

下载用户的所有帖子

# 下载公开用户的所有帖子(图片 + 视频 + 元数据)
instaloader profile_name

# 登录后下载(访问更多内容)
instaloader --login YOUR_USERNAME profile_name
import instaloader

L = instaloader.Instaloader()

# 下载用户的所有帖子
profile = instaloader.Profile.from_username(L.context, "profile_name")

for post in profile.get_posts():
    L.download_post(post, target="profile_name")

输出文件结构

instaloader 默认按用户名创建文件夹:

./profile_name/
  ├── 2024-01-15_12-30-00_UTC.jpg       # 图片
  ├── 2024-01-15_12-30-00_UTC.json.xz   # 元数据(压缩)
  ├── 2024-01-15_12-30-00_UTC.txt        # 说明文字
  ├── 2024-01-14_08-00-00_UTC.mp4        # 视频
  ├── 2024-01-14_08-00-00_UTC.json.xz
  ├── 2024-01-14_08-00-00_UTC.txt
  └── ...

选择下载内容

# 不下载视频
instaloader --no-videos profile_name

# 不保存元数据
instaloader --no-metadata-json profile_name

# 不保存说明文字
instaloader --no-captions profile_name

# 只要图片(不要视频、元数据、说明文字)
instaloader --no-videos --no-metadata-json --no-captions profile_name

下载单个帖子

# 通过帖子短码下载
instaloader -- -CxxxxxxYYYY

# 注意 -- 后面的短码前要加 - 号
import instaloader

L = instaloader.Instaloader()

# 通过短码获取帖子
post = instaloader.Post.from_shortcode(L.context, "CxxxxxxYYYY")
L.download_post(post, target="downloads")

帖子短码就是 URL 中 /p/ 后面的部分,例如 instagram.com/p/CxxxxxxYYYY/ 中的 CxxxxxxYYYY

On this page