名称: 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)"}]}}
使用 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_MS、GRAM_COOKIE_TIMEOUT_MS
gram query-ids --refresh
--cookie-source--chrome-profile-dir--session-id、--csrf-token、--ds-user-id总结:通过命令行查看 Instagram 动态、个人资料、搜索内容并进行互动。📸