byj-pupshot
v1.0.0
Published
Simple CLI to take screenshots with Puppeteer
Readme
Puppeteer Screenshot CLI
Puppeteer로 특정 URL의 스크린샷을 찍어 저장하는 간단한 CLI 스크립트입니다.
설치
패키지로 설치
npm i byj-pupshot로컬 개발
npm init -y
npm i puppeteer사용법
패키지 설치 후
byj-pupshot --url https://example.comnpx로 바로 실행
npx byj-pupshot --url https://example.com./screenshot.js --url https://example.com --full-page주요 옵션
--url <URL>: 대상 URL (필수)--path <FILE>: 저장 경로 (기본:./out/<time>_<hostname>.<ext>)--type <png|jpeg|webp>: 이미지 포맷 (기본: png)--quality <0-100>: JPEG/WEBP 품질--full-page: 전체 페이지 캡처--clip x,y,w,h: 특정 영역 캡처--viewport w,h: 뷰포트 크기 (기본: 1280,720)--device-scale <number>: deviceScaleFactor--omit-background: 배경 투명 (PNG)--wait-until <event>:load | domcontentloaded | networkidle0 | networkidle2--timeout <ms>: 네비게이션 타임아웃 (기본: 30000)--delay <ms>: 캡처 전 추가 대기--wait-selector <css>: 특정 셀렉터 대기--user-agent <string>: User-Agent 설정--http-auth <user:pass>: HTTP Basic Auth--headers-json <json>: 추가 헤더 JSON--cookies-json <json>: 쿠키 JSON 배열--headless/--no-headless: 헤드리스 모드 설정
헤더/쿠키 환경변수
헤더
PUPPETEER_HEADERS='{"X-Test":"1","Authorization":"Bearer ..."}' \
./screenshot.js --url https://example.com --path out.png쿠키(JSON 배열)
PUPPETEER_COOKIES='[{"name":"sid","value":"abc","domain":"example.com"}]' \
./screenshot.js --url https://example.com --path out.png쿠키 문자열
도메인/URL이 없는 쿠키는 대상 URL로 자동 보정됩니다.
PUPPETEER_COOKIE_STRING='a=b; c=d' \
./screenshot.js --url https://example.com --path out.png예시
PUPPETEER_HEADERS='{"X-Test":"1"}' \
PUPPETEER_COOKIES='[{"name":"sid","value":"abc","domain":"example.com"}]' \
./screenshot.js --url https://example.com --path out.png --full-page주의사항
--clip과--full-page는 동시에 사용할 수 없습니다.--quality는jpeg또는webp일 때만 적용됩니다.
