Codex에서 웹 스크래핑
Codex에 Spicrawl MCP 서버를 추가하세요. 그러면 웹 페이지를 깔끔한 Markdown으로 읽을 수 있습니다.
설정하기
세 단계로 Codex에 도구, Spicrawl 코드를 작성하는 노하우, 둘을 쓰는 규칙을 갖춰 줍니다. 세 단계를 한 번에 하려면 spicrawl init --client codex를 사용하세요.
API 키를 설정하세요:
bashexport SPICRAWL_API_KEY=spicrawl_live_... # add to your shell profileMCP 서버를 추가하세요. Codex는 연결할 때마다
SPICRAWL_API_KEY에서 키를 읽으므로 키가 파일에 남지 않습니다:bashcodex mcp add spicrawl --url https://mcp.spicrawl.com/mcp --bearer-token-env-var SPICRAWL_API_KEY이는 다음 설정과 같은 내용을 기록합니다:
~/.codex/config.toml[mcp_servers.spicrawl] url = "https://mcp.spicrawl.com/mcp" bearer_token_env_var = "SPICRAWL_API_KEY"프로젝트 하나에만 적용하려면 테이블을
.codex/config.toml에 넣으세요. Codex는 신뢰할 수 있는 프로젝트에서만 이를 읽습니다.스킬을 설치하세요:
bashmkdir -p .agents/skills/spicrawl curl -fsSL https://app.spicrawl.com/skill.md -o .agents/skills/spicrawl/SKILL.md프로젝트 루트의
AGENTS.md에 이 섹션을 붙여 넣으세요: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또는 세션에서/mcp로 확인하세요.spicrawl_*도구 25개가 보여야 합니다.
또는 CLI 사용
Codex는 셸에서 동작하므로 spicrawl CLI는 설정 없이도 작동합니다. 파이프로 연결하면 JSON을 출력하고 일정한 코드로 종료합니다:
spicrawl scrape https://example.com/pricing --format markdown --max-cost 3 | jq -r .contentCodex 클라우드에서는 MCP 서버에 의존하지 마세요. CLI나 일반 HTTP를 사용하세요. SPICRAWL_API_KEY는 시크릿이 아니라 환경 변수로 설정하고, 에이전트의 인터넷 접근에서 api.spicrawl.com를 허용하세요.
먼저 해 볼 작업
프로젝트에서 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.할 수 있는 일
이 서버는 에이전트에게 spicrawl_* 도구 25개를 제공합니다. 각 호출은 API를 직접 호출할 때와 같은 한도와 크레딧으로 사용자의 API 키로 실행됩니다.
- 페이지 하나 읽기:
spicrawl_scrape는 Markdown(기본값), 텍스트, HTML, JSON 또는 PDF를 반환합니다. - 여러 페이지 읽기:
spicrawl_batch_submit는 최대 10,000개의 URL을 대기열에 넣습니다. 이어서spicrawl_batch_status와spicrawl_batch_results를 사용하세요. - 로그인이 필요한 페이지:
spicrawl_session_create는 호출 사이에 쿠키와 스토리지를 유지합니다. - 실패 디버깅:
spicrawl_requests_list와spicrawl_request_get. - 사용량 확인:
spicrawl_usage_summary및 기타 사용량 도구입니다. 이 도구에는read범위가 있는 키가 필요합니다. - 조회하기:
spicrawl_docs_search와spicrawl_docs_read로 Spicrawl 문서를 검색하고 읽습니다.
도구 하나, spicrawl_browser_connect_url는 목록에 있지만 곧 제공될 예정입니다. spicrawl_scrape에서 렌더링 인수는 API의 js_render가 아니라 render입니다.
알아 두세요
- 크롤링은 지원하지 않습니다. Spicrawl은 링크를 따라가거나 페이지를 찾지 않습니다. 에이전트에게 URL을 주세요.
- 요청당 크레딧. 일반 fetch는 1 크레딧, JavaScript 렌더링은 3, 전체 브라우저 렌더링은 8입니다.
- 실패는 무료입니다. 실패한 요청은 0 크레딧입니다.
- 캐시는 시간을 절약해 줄 뿐 크레딧을 절약해 주지는 않습니다. 캐시 적중 비용은 그 결과를 저장한 요청과 같습니다.
- 호출마다 상한을 두세요.
max_cost를 설정하면 더 많은 비용이 들 수 있는 요청은 실행 전에 거부됩니다. - 곧 제공 예정: 관리형 프록시, 스텔스 모드, 원격 브라우저, 일반 문장 프롬프트를 이용한 AI 추출. 현재는 직접 프록시를 사용할 수 있습니다.
자주 묻는 질문
Codex는 서버를 어디에 저장하나요?
~/.codex/config.toml에 넣으세요. 한 프로젝트에서만 쓰려면 같은 표를 .codex/config.toml에 넣으세요. Codex는 신뢰하는 프로젝트에서만 프로젝트 설정을 읽습니다.
Codex에서 MCP 대신 CLI를 쓸 수 있나요?
예. Codex는 셸에서 작동하므로 spicrawl scrape URL --format markdown --max-cost 3을 실행할 수 있습니다. CLI는 파이프로 연결하면 JSON을 출력하고 안정적인 종료 코드로 끝납니다.
Codex 클라우드에서도 작동하나요?
그곳에서는 MCP 서버를 기대하지 마세요. CLI나 일반 HTTP를 사용하세요. SPICRAWL_API_KEY를 (비밀 값이 아닌) 환경 변수로 설정하고, 에이전트의 인터넷 접근에서 api.spicrawl.com을 허용하세요.
서버가 401을 반환하는 이유는 무엇인가요?
SPICRAWL_API_KEY가 codex를 시작한 셸에 설정되어 있지 않았습니다. export한 다음 새 세션을 시작하세요.
페이지당 비용이 얼마인가요?
일반 fetch는 1 크레딧, JavaScript 렌더링은 3, 풀 브라우저 렌더링은 8입니다. 실패한 요청은 0 크레딧입니다. 캐시 적중은 그 결과를 저장한 fetch와 같은 비용이 듭니다. 에이전트가 예상보다 많이 쓰지 않도록 요청마다 max_cost를 설정하게 하세요.