OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  gram:Instagram 命令行工具:资讯流、发帖及互动

gram:Instagram 命令行工具:资讯流、发帖及互动

 
  runtime ·  2026-02-05 15:41:52 · 3 次点击  · 0 条评论  

名称: gram
描述: 通过 Cookie 查看 Instagram 动态、帖子、个人资料及进行互动的命令行工具。
主页: https://github.com/arein/gram
元数据: {"clawdbot":{"emoji":"📸","requires":{"bins":["gram"]},"install":[{"id":"npm","kind":"node","package":"@cyberdrk/gram","bins":["gram"],"label":"安装 gram (npm)"}]}}


gram 📸

使用 REST/GraphQL API 及 Cookie 认证的 Instagram 命令行工具。

安装

# npm/pnpm/bun
npm install -g @cyberdrk/gram

# 单次运行(无需安装)
bunx @cyberdrk/gram whoami

认证

gram 使用来自 Instagram 网页会话的 Cookie 进行认证。

可直接通过 --session-id--csrf-token--ds-user-id 传递 Cookie,或使用 --cookie-source 从浏览器获取 Cookie。

运行 gram check 查看当前使用的认证来源。对于 Arc/Brave 浏览器,请使用 --chrome-profile-dir <路径>

命令

账户与认证

gram whoami                    # 显示当前登录账户
gram check                     # 显示凭证来源
gram query-ids --refresh       # 刷新 GraphQL 查询 ID 缓存

查看帖子

gram post <短代码或URL>        # 查看帖子
gram <短代码或URL>             # 查看帖子的简写形式
gram comments <短代码> -n 20   # 查看帖子评论(显示 20 条)
gram likers <短代码>           # 查看点赞该帖子的用户

动态

gram feed -n 20                # 首页动态(显示 20 条)
gram explore -n 20             # 探索/发现动态(显示 20 条)

用户资料

gram user <用户名>             # 查看用户资料
gram user @instagram --json    # 以 JSON 格式输出
gram posts <用户名> -n 20      # 查看用户的帖子(显示 20 条)
gram following [用户名]        # 查看关注列表(默认为当前用户)
gram followers [用户名]        # 查看粉丝列表(默认为当前用户)

搜索

gram search "查询词"           # 搜索用户、话题标签、地点
gram search "coffee" --type users
gram search "nyc" --type places
gram search "#photography" --type hashtags

互动操作

gram like <短代码>             # 点赞帖子
gram unlike <短代码>           # 取消点赞
gram save <短代码>             # 收藏/保存帖子
gram unsave <短代码>           # 取消收藏
gram comment <短代码> "评论内容" # 评论帖子
gram follow <用户名>           # 关注用户
gram unfollow <用户名>         # 取消关注用户

输出选项

--json          # 输出 JSON 格式
--json-full     # 输出 JSON 格式,并在 _raw 字段中包含原始 API 响应
--plain         # 无表情符号、无颜色(适用于脚本处理)
--no-emoji      # 禁用表情符号
--no-color      # 禁用 ANSI 颜色(或设置环境变量 NO_COLOR=1)

全局选项

--session-id <token>           # Instagram sessionid Cookie
--csrf-token <token>           # Instagram csrftoken Cookie
--ds-user-id <id>              # Instagram ds_user_id Cookie
--cookie-source <来源>         # 浏览器 Cookie 来源(可重复使用)
--chrome-profile <名称>        # Chrome 浏览器配置文件名称
--chrome-profile-dir <路径>    # Chrome/Chromium 配置文件目录或 Cookie 数据库路径
--firefox-profile <名称>       # Firefox 浏览器配置文件
--timeout <毫秒>               # 请求超时时间
--cookie-timeout <毫秒>        # Cookie 提取超时时间

配置文件

全局配置文件 ~/.config/gram/config.json5 或项目级配置文件 ./.gramrc.json5

{
  cookieSource: ["safari", "chrome"],
  chromeProfile: "Profile 1",
  timeoutMs: 60000
}

环境变量:GRAM_TIMEOUT_MSGRAM_COOKIE_TIMEOUT_MS

故障排除

查询 ID 过期(404 错误)

gram query-ids --refresh
  • 确认浏览器已登录 Instagram
  • 尝试不同的 --cookie-source
  • 对于 Arc/Brave 浏览器:使用 --chrome-profile-dir
  • 手动提供 Cookie:--session-id--csrf-token--ds-user-id

用户代理不匹配错误

  • 默认使用桌面版用户代理
  • 如果会话是在移动端创建的,可能会失败
  • 请通过桌面浏览器重新登录以创建新会话

总结:通过命令行查看 Instagram 动态、个人资料、搜索内容并进行互动。📸

3 次点击  ∙  0 人收藏  
登录后收藏  
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor