Instagram Skill via cyberdrk/gram CLI技能使用说明
2026-03-29
新闻来源:网淘吧
围观:14
电脑广告
手机广告
gram 📸
使用 REST/GraphQL API + cookie 认证的 Instagram 命令行工具。
安装
# npm/pnpm/bun
npm install -g @cyberdrk/gram
# One-shot (no install)
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 # Show logged-in account
gram check # Show credential sources
gram query-ids --refresh # Refresh GraphQL query ID cache
阅读帖子
gram post <shortcode-or-url> # View a post
gram <shortcode-or-url> # Shorthand for post
gram comments <shortcode> -n 20 # View comments on a post
gram likers <shortcode> # View users who liked a post
动态
gram feed -n 20 # Home feed
gram explore -n 20 # Explore/discover feed
用户档案
gram user <username> # View user profile
gram user @instagram --json # JSON output
gram posts <username> -n 20 # User's posts
gram following [username] # Users someone follows (defaults to you)
gram followers [username] # Someone's followers (defaults to you)
搜索
gram search "query" # Search users, hashtags, places
gram search "coffee" --type users
gram search "nyc" --type places
gram search "#photography" --type hashtags
互动操作
gram like <shortcode> # Like a post
gram unlike <shortcode> # Unlike a post
gram save <shortcode> # Save/bookmark a post
gram unsave <shortcode> # Unsave a post
gram comment <shortcode> "nice!" # Comment on a post
gram follow <username> # Follow a user
gram unfollow <username> # Unfollow a user
输出选项
--json # JSON output
--json-full # JSON with raw API response in _raw field
--plain # No emoji, no color (script-friendly)
--no-emoji # Disable emoji
--no-color # Disable ANSI colors (or set 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 <source> # Cookie source for browser cookies (repeatable)
--chrome-profile <name> # Chrome profile name
--chrome-profile-dir <path> # Chrome/Chromium profile dir or cookie DB path
--firefox-profile <name> # Firefox profile
--timeout <ms> # Request timeout
--cookie-timeout <ms> # Cookie extraction timeout
配置文件
~/.config/gram/config.json5(全局)或./.gramrc.json5(项目):
{
cookieSource: ["safari", "chrome"],
chromeProfile: "Profile 1",
timeoutMs: 60000
}
环境变量:GRAM_TIMEOUT_MS、GRAM_COOKIE_TIMEOUT_MS
故障排除
查询ID已过期(404错误)
gram query-ids --refresh
Cookie提取失败
- 检查浏览器是否已登录Instagram
- 尝试不同的
--cookie-source - 对于Arc/Brave浏览器:使用
--chrome-profile-dir - 手动提供Cookie:
--session-id、--csrf-token,--ds-user-id
用户代理不匹配错误
- 命令行界面默认使用桌面用户代理
- 如果您的会话是在移动设备上创建的,则可能失败
- 通过桌面浏览器登录以创建新会话
太长不看版: 通过命令行界面查看动态、个人资料、搜索并与Instagram互动。📸
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~