← 返回
AI智能 中文

Grok Scraper

Execute queries to Grok AI via Playwright browser automation without requiring an X API KEY. Use when the user wants to "ask Grok", search X for real-time in...
通过 Playwright 浏览器自动化执行 Grok AI 查询,无需 X API KEY。适用于用户想要“询问 Grok”或在 X 上搜索实时信息等场景。
aquarius-wing
AI智能 clawhub v0.1.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 559
下载
💾 7
安装
1
版本
#latest

概述

Grok Scraper

Preview

Agent Context: This is a zero-cost alternative to official X APIs. It uses a real browser session (Playwright) via an X Premium account. ALWAYS use this skill when the user wants to query Grok but does not have or want to use an X API KEY.

Prerequisites

  • OpenClaw must be installed on the host machine.
  • A display/GUI environment is required. This skill launches a real browser window for login. It cannot run on headless cloud servers (no screen). It must be used on a local machine or a remote desktop with a display.
  • The user must be logged in to x.com via the browser session saved by npm run login. Without a valid session, all queries will fail.

First-Time Setup

Run these commands once after cloning the repo, before doing anything else:

cd scripts
npm install
npx playwright install chromium

Then log in to x.com to create a session:

npm run login
# A browser window will open — log in to x.com manually, then return to the terminal and press Enter

The session/ directory will be created automatically after a successful login.

Workflow

Step 1: Check Login State

  • If session/ directory does not exist: stop and ask the user to run cd scripts && npm run login.
  • If it exists: proceed.

Step 2: Execute Query

scripts/run.sh "The user's detailed prompt"

run.sh handles logging, automatic retry on Grok service errors, and login-expiry detection. It is the canonical entry point for all queries.

Step 3: Read Output

  • Exit Code 0 → read output/latest.md and present the result.
  • Other exit codes → see Error Handling below.

Error Handling

Exit CodeMeaningAction
----------------------------
0SuccessRead output/latest.md
2Session expiredAsk user to run cd scripts && npm run login
3Grok service errorrun.sh already retried once; report failure to user
1Extraction failedCheck if output/debug-dom.json was written → if yes, DOM selectors may have broken — see dom-selector-fix.md

DOM Selectors Breaking

Twitter/X redeploys its front-end regularly, which changes the CSS class names this scraper relies on. If extraction fails with Method: none, follow the fix guide:

dom-selector-fix.md

Examples

Standard query

scripts/run.sh "Search for the latest AI news and format as markdown"
# → read output/latest.md

Session expired

  1. Run scripts/run.sh → Exit Code 2
  2. Tell user: "Session expired, please run cd scripts && npm run login"

DOM selectors broken

  1. Run scripts/run.sh → Exit Code 1, output/debug-dom.json exists
  2. Follow dom-selector-fix.md to identify new classes and update SELECTORS in scripts/scrape.js

Debugging

When diagnosing scraper issues directly, use the bare command — it skips logging and retry logic, making failures easier to inspect.

FlagExampleDescription
----------------------------
_(none)_npm run scrapeRun with default prompt
"prompt"npm run scrape -- "Your question"Custom prompt
--recordnpm run scrape -- --recordRecord video to output/grok-.webm
--record npm run scrape -- --record out.webmRecord video to custom path (relative → output/)
--size WxHnpm run scrape -- --record --size 1920x1080Set recording resolution (default: 1280x800)

All flags can be combined:

cd scripts
npm run scrape -- "Your prompt" --record --size 1920x1080

When --record is active, the browser runs in headed mode (visible window) with slowMo: 50ms; without it, headless mode is used.

版本历史

共 1 个版本

  • v0.1.1 当前
    2026-03-30 03:03 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,769
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,006
ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 837 📥 213,304