Gemini CLI में web scraping
Gemini CLI में Spicrawl MCP server जोड़ें। फिर यह web pages को साफ़ Markdown में पढ़ सकता है।
Set up करें
spicrawl init Gemini CLI को support नहीं करता, इसलिए ये steps अपनाएँ।
अपनी key सेट करें, फिर उसे दूसरे नाम पर copy करें:
bashexport SPICRAWL_API_KEY=spicrawl_live_... # add to your shell profile export SPICRAWL_MCP_BEARER="$SPICRAWL_API_KEY"Gemini CLI headers भरने से पहले उन variables को हटा देता है जिनके नाम में
KEY,TOKEN,AUTHया ऐसे ही शब्द हों। इसलिए$SPICRAWL_API_KEYखाली रह जाएगा और server 401 देगा।Server को
~/.gemini/settings.jsonमें जोड़ें (या किसी एक project के लिए.gemini/settings.jsonमें)।urlनहीं,httpUrlइस्तेमाल करें:~/.gemini/settings.json{ "mcpServers": { "spicrawl": { "httpUrl": "https://mcp.spicrawl.com/mcp", "headers": { "Authorization": "Bearer $SPICRAWL_MCP_BEARER" } } } }या वही entry command line से जोड़ें। Single quotes variable reference को file में रखते हैं:
bashgemini mcp add --scope user --transport http \ --header 'Authorization: Bearer $SPICRAWL_MCP_BEARER' \ spicrawl https://mcp.spicrawl.com/mcpSkill install करें, फिर चल रहे session में
/skills reloadचलाएँ:bashspicrawl skill install --client codex # Without the CLI: mkdir -p .agents/skills/spicrawl curl -fsSL https://app.spicrawl.com/skill.md -o .agents/skills/spicrawl/SKILL.mdइस section को project root में
GEMINI.mdमें paste करें, फिर/memory reloadचलाएँ:GEMINI.md# Web data (Spicrawl) Use Spicrawl to read web pages: the spicrawl_* MCP tools in chat, 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. - Never print or commit SPICRAWL_API_KEY. Log `X-Request-Id` for failures.geminiशुरू करें और/mcpचलाएँ।spicrawlको 25spicrawl_*tools के साथ connected दिखना चाहिए।
आज़माने के लिए पहला task
Project में gemini शुरू करें और पूछें:
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.Agent को format: "markdown" के साथ spicrawl_scrape call करना चाहिए। Gemini CLI हर tool call की पुष्टि माँगता है, जब तक server में "trust": true न हो।
यह क्या कर सकता है
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 ला सकते हैं।
अक्सर पूछे जाने वाले सवाल
Header में SPICRAWL_API_KEY क्यों इस्तेमाल न करें?
Gemini CLI headers expand करने से पहले उन variables को हटा देता है जिनके नामों में KEY, TOKEN, AUTH और ऐसे शब्द होते हैं। $SPICRAWL_API_KEY खाली होता और server 401 देता। SPICRAWL_MCP_BEARER इस्तेमाल करें।
क्या spicrawl init Gemini CLI को support करता है?
नहीं। इस page के manual steps follow करें।
क्या मुझे url इस्तेमाल करना चाहिए या httpUrl?
httpUrl इस्तेमाल करें। Gemini CLI में url का मतलब SSE है, और Spicrawl server Streamable HTTP इस्तेमाल करता है।
क्या Gemini CLI के लिए Spicrawl extension है?
नहीं। कोई Spicrawl extension published नहीं है, इसलिए settings entry इस्तेमाल करें।
हर page की कीमत कितनी है?
Plain fetch की कीमत 1 credit है, JavaScript rendering की 3 और full-browser rendering की 8। Failed requests की कीमत 0। Cache hit की कीमत उतनी ही है जितनी उस fetch की जिसने इसे store किया। Agent से हर request पर max_cost सेट करने को कहें ताकि वह आपकी उम्मीद से ज़्यादा खर्च न करे।