Codex में web scraping
Codex में Spicrawl MCP server जोड़ें। फिर यह web pages को साफ़ Markdown में पढ़ सकता है।
Set up करें
तीन steps Codex को tools, Spicrawl code लिखने की जानकारी, और दोनों के इस्तेमाल के नियम देते हैं। या तीनों spicrawl init --client codex से एक साथ कर लें।
अपनी API key सेट करें:
bashexport SPICRAWL_API_KEY=spicrawl_live_... # add to your shell profileMCP server जोड़ें। Codex हर बार connect होते समय key को
SPICRAWL_API_KEYसे पढ़ता है, इसलिए key कभी किसी file में नहीं जाती:bashcodex mcp add spicrawl --url https://mcp.spicrawl.com/mcp --bearer-token-env-var SPICRAWL_API_KEYयह वही लिखता है जो इस config में है:
~/.codex/config.toml[mcp_servers.spicrawl] url = "https://mcp.spicrawl.com/mcp" bearer_token_env_var = "SPICRAWL_API_KEY"सिर्फ़ एक project के लिए, table को
.codex/config.tomlमें रखें। Codex इसे सिर्फ़ trusted projects में पढ़ता है।Skill install करें:
bashmkdir -p .agents/skills/spicrawl curl -fsSL https://app.spicrawl.com/skill.md -o .agents/skills/spicrawl/SKILL.mdइस section को project root में
AGENTS.mdमें paste करें:AGENTS.md## Web data (Spicrawl) Use Spicrawl to read web pages: the spicrawl_* MCP tools, the `spicrawl` CLI, or POST https://api.spicrawl.com/v1/scrape with `Authorization: Bearer $SPICRAWL_API_KEY` in code. Docs: https://docs.spicrawl.com/llms.txt (append .md to any page URL for Markdown). - Ask for markdown: `response_format: "markdown"` (API default is html); on spicrawl_scrape, `format: "markdown"`. - Check the site's status, not only the HTTP status: `X-Target-Status` header, or `status` in the JSON envelope (spicrawl_scrape with `format: "json"`). 200 is the page; 404/410 mean it does not exist; 403/429/503 mean the site refused, so escalate. - On an error, switch on `code`. Retry only when `retryable` is true, after `retry_after_seconds`. Read `diagnostics.hint` and change what it names first. Never retry ERR::REQUEST::*, ERR::AUTH::* or ERR::LIMIT::QUOTA_EXCEEDED. - Escalate one step at a time and stop at the first that works: plain fetch (1 credit) -> `js_render: true` (3) -> add the user's own `proxy` if they have one. Empty or skeleton content means render; ERR::UPSTREAM::CHALLENGE or a 403 target status means retry once, then the user's own proxy. - Set `max_cost` on every request to the price of the step you intend. - Keep the cache on (default). Set `cache: false` only for prices, stock or other live data. - Trim tokens with `main_content_only` (on by default for markdown), `include_tags`, `exclude_tags`. - For more than 20 URLs, use a batch job (spicrawl_batch_submit / POST /v1/batch). Batch items return html, markdown or text (spicrawl_batch_submit defaults to markdown, POST /v1/batch to html). Extraction, screenshots, actions and sessions are refused with a 400 before anything is charged: scrape those URLs one by one. - With the CLI, read stdout as JSON and branch on the exit code: 3 auth, 4 bad request, 5 limit, 6 site refused or failed, 7 proxy, 8 engine or extraction, 10 network. - Never print or commit SPICRAWL_API_KEY. Log `X-Request-Id` for failures.इसे
codex mcp listसे जाँचें, या session में/mcpसे। आपको 25spicrawl_*tools दिखने चाहिए।
या CLI इस्तेमाल करें
Codex shell में काम करता है, इसलिए spicrawl CLI बिना किसी config के चलता है। Pipe करने पर यह JSON print करता है और एक stable code के साथ exit होता है:
spicrawl scrape https://example.com/pricing --format markdown --max-cost 3 | jq -r .contentCodex cloud में MCP server के भरोसे न रहें। CLI या plain HTTP इस्तेमाल करें। SPICRAWL_API_KEY को secret नहीं, environment variable के रूप में set करें, और agent की internet access में api.spicrawl.com को allow करें।
आज़माने के लिए पहला task
Project में codex शुरू करें और पूछें:
Use Spicrawl to read https://example.com/pricing as markdown. List each plan with its monthly price.
If the page comes back empty, retry with rendering.यह क्या कर सकता है
Server agent को 25 spicrawl_* tools देता है। हर call आपकी API key के तहत चलती है, उन्हीं limits और credits के साथ जो सीधी API call में होते हैं।
- एक page पढ़ें:
spicrawl_scrapeMarkdown (default), text, HTML, JSON या PDF लौटाता है। - कई pages पढ़ें:
spicrawl_batch_submitएक बार में 10,000 URLs तक queue करता है। इसके बादspicrawl_batch_statusऔरspicrawl_batch_resultsचलाएँ। - Login के पीछे के pages:
spicrawl_session_createcalls के बीच cookies और storage बनाए रखता है। - Failure debug करें:
spicrawl_requests_listऔरspicrawl_request_get। - Usage जाँचें:
spicrawl_usage_summaryऔर बाकी usage tools। इनके लिएreadscope वाली key चाहिए। - चीज़ें खोजें:
spicrawl_docs_searchऔरspicrawl_docs_readSpicrawl docs खोजते और पढ़ते हैं।
एक tool, spicrawl_browser_connect_url, listed है लेकिन जल्द आ रहा है। spicrawl_scrape पर rendering argument render है, न कि API का js_render।
जानने लायक बातें
- Crawling नहीं। Spicrawl links follow नहीं करता और pages नहीं ढूँढता। Agent को URLs दें।
- प्रति request credits। Plain fetch 1 credit का है। JavaScript rendering 3 का। Full-browser rendering 8 का।
- Failures free हैं। Fail हुई request की कीमत 0 credits है।
- Cache समय बचाता है, credits नहीं। Cache हिट की कीमत उसी fetch जितनी है जिसने उसे store किया था।
- हर call की सीमा तय करें।
max_costset करें, और जो request ज़्यादा खर्च कर सकती है उसे चलने से पहले ही refuse कर दिया जाता है। - जल्द आ रहा है: managed proxies, stealth mode, एक remote browser और एक plain-language prompt से AI extraction। आज आप अपना proxy ला सकते हैं।
अक्सर पूछे जाने वाले सवाल
Codex server को कहाँ store करता है?
~/.codex/config.toml में। इसे सिर्फ़ एक project में इस्तेमाल करने के लिए, वही table .codex/config.toml में रखें। Codex project config सिर्फ़ trusted projects में पढ़ता है।
क्या Codex MCP की जगह CLI इस्तेमाल कर सकता है?
हाँ। Codex shell में काम करता है, इसलिए वह spicrawl scrape URL --format markdown --max-cost 3 चला सकता है। CLI pipe करने पर JSON print करता है और stable code के साथ exit होता है।
क्या यह Codex cloud में काम करता है?
वहाँ MCP server पर भरोसा न करें। CLI या plain HTTP इस्तेमाल करें। SPICRAWL_API_KEY को environment variable (secret नहीं) के रूप में सेट करें और agent के internet access में api.spicrawl.com की अनुमति दें।
Server 401 क्यों लौटाता है?
SPICRAWL_API_KEY उस shell में सेट नहीं थी जिसने codex शुरू किया। इसे export करें और नया session शुरू करें।
हर page की कीमत कितनी है?
Plain fetch की कीमत 1 credit है, JavaScript rendering की 3 और full-browser rendering की 8। Failed requests की कीमत 0। Cache hit की कीमत उतनी ही है जितनी उस fetch की जिसने इसे store किया। Agent से हर request पर max_cost सेट करने को कहें ताकि वह आपकी उम्मीद से ज़्यादा खर्च न करे।