docs(skill): 셀렉터 자가치유 예시의 storage_args 는 .css() 인자가 아니다 — configure() 로 옮기고 kwargs 계약 테스트 추가 - #3
Open
Gforce10-design wants to merge 1 commit into
Conversation
… 로 옮기고 kwargs 계약 테스트 추가
문서 3곳(SKILL.md § 셀렉터 자가 치유, scripts/scrapling_reference.md §7·§8)이
page.css(SEL, auto_save=True, storage_args={"storage_file": "./fingerprints/elements_storage.db"})
를 보여주는데, requirements.txt 가 고정한 scrapling[fetchers]>=0.4.8,<0.5 에서
설치되는 0.4.15 의 시그니처는
Selector.css(selector, identifier='', adaptive=False, auto_save=False, percentage=40)
라 storage_args 가 없다. 문서대로 옮겨 적은 crawl_script.py 는 수집 도중 죽는다.
실측 2026-09-01 books.toscrape.com:
TypeError: Selector.css() got an unexpected keyword argument 'storage_args'
실제 API(0.4.15 소스): storage_args 는 파서를 *만드는* 쪽의 인자다 —
Selector.__init__(... adaptive, storage, storage_args)(parser.py:93-105) 이고
Fetcher.configure(adaptive=True, storage_args={...})(custom.py:205-227) 로 전역 지정,
요청별로는 selector_config={...}. 생성 시 adaptive=True 가 없으면 css() 의
auto_save/adaptive 는 경고만 남기고 무시된다(parser.py:176-194). url 을 함께 주면
도메인별 버킷으로 저장된다(storage.py:24-27). 세션(FetcherSession)은 configure()
를 읽지 않아 plain_session(selector_config=...) 로 따로 넘겨야 한다.
수정:
- 문서 3곳을 Fetcher.configure(adaptive=True, storage_args=...) 방식으로. 저장 실패가
수집을 죽이지 않게 try/except 폴백 예시 추가. 세션 주의·기본 경로(site-packages 안)
주의 추가.
- CLAUDE.md:312 산문도 같은 오용을 암시해 정정.
- scripts/test_doc_contracts.py 섹션 4: 문서 python 블록의 .css() 호출 kwargs 를
inspect.signature(Selector.css) 와 대조. 원본 문서로 돌리면 6건 실패, 수정 후 통과.
- .codex/skills 미러 재생성(sync_codex_mirror.py, --check exit 0).
왜 기존 계약 테스트가 못 잡았나: test_doc_contracts 가 코드블록의 import 대상만
실제 모듈과 대조하고 호출 kwargs 는 보지 않았다.
검증: 고쳐진 문서 블록 3개를 네트워크 차단 상태에서 로컬 HTML 로 그대로 exec —
TypeError 없음, 지정 경로에 DB 생성, 셀렉터를 깨뜨린 HTML 에서 adaptive 재탐색 성공.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoBwBJZ5FyNxkbcX2RpCZT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
문서의 셀렉터 자가치유 예시
page.css(SEL, auto_save=True, storage_args={...})가 이 저장소가 스스로 고정한 scrapling 0.4.x 에서 TypeError 를 낸다. 문서대로 옮겨 적은crawl_script.py는 수집 도중 죽는다.재현 (upstream
c64cfbf)실측 2026-09-01 books.toscrape.com:
문서 위치:
.claude/skills/web-crawler/SKILL.md§ 셀렉터 자가 치유,scripts/scrapling_reference.md§7·§8 (+CLAUDE.md:312산문).실제 API (0.4.15 소스)
storage_args는 파서를 만드는 쪽 인자 —Selector.__init__(... adaptive, storage, storage_args)(parser.py:93-105)Fetcher.configure(adaptive=True, storage_args={"storage_file": ..., "url": url})(engines/toolbelt/custom.py:205-227) — 파서 전용 configure 가 바로 이 용도selector_config={...}(fetchers/requests.py:24-31에서 configure 값과 병합)adaptive=True가 없으면css()의auto_save/adaptive는 경고만 남기고 무시된다 (parser.py:176-194)url을 주면 도메인별 버킷 (core/storage.py:24-27); 안 주면default하나FetcherSession은configure()를 읽지 않는다 —plain_session(selector_config=...)로 따로 넘겨야 함 (engines/static.py:87,677)scrapling/elements_storage.db(parser.py:47) — venv 지우면 핑거프린트도 사라진다왜 기존 계약 테스트가 못 잡았나
test_doc_contracts.py가 코드블록의 import 대상만 실제 모듈과 대조하고 호출 kwargs 는 보지 않았다.수정
Fetcher.configure(adaptive=True, storage_args=...)방식으로. 저장 실패가 수집을 죽이지 않게 try/except 폴백 예시. 세션 주의·기본 경로 주의 추가.CLAUDE.md:312산문 정정.test_doc_contracts.py섹션 4 신설: 문서 python 블록을ast로 파싱해.css()호출 kwargs 를inspect.signature(Selector.css)와 대조. 원본 문서로 돌리면 6건 실패, 수정 후 통과..codex/skills미러 재생성 (sync_codex_mirror.py --checkexit 0).검증
pytest -q -k "not e2e"→ 425 passed.sync_codex_mirror.py --check/sync_domain_list.py --checkexit 0.div.item→div.product)에서adaptive=True재탐색 성공.참고
scripts/scrapling_reference.md는 기존DOC_FILES에 없어 import 검사를 받지 않는다(예: §6 의AsyncFetcherSession). 이번엔 css-kwargs 검사에만 추가했다.DOC_FILES편입 여부는 별도 판단.🤖 Generated with Claude Code
https://claude.ai/code/session_01KoBwBJZ5FyNxkbcX2RpCZT