모든 종속성이 포함된 로그인된 페이지를 가져오는 간단한 명령이 있습니다.
wget --post-data='user=user&password=password' --page-requisites https://…/login
서버 로그에는 다음이 표시됩니다(명백한 이유로 축약됨).
- POST /로그인 302
- GET /계정 200
- POST /robots.txt 200(GET이어야 하지만 성공하므로 문제 없음)
- POST /favicon.ico 200 (동일)
- POST /[looong PageSpeed URL]500(페이지의 모든 CSS, JavaScript 및 이미지 파일에 대해)
이러한 파일을 가져오는 것은 잘 작동하므로 URL은 정확하지만 PageSpeed는 클라이언트 게시를 좋아하지 않는 것 같습니다.wget
초기 요청을 제외한 모든 작업에 GET을 사용 하려면 어떻게 해야 하나요 ?
GNU Wget 1.18을 사용합니다.
업데이트:벌레제출된.
답변1
'man wget'에서:
This example shows how to log in to a server using POST and then proceed to download the desired pages, presumably only accessible to authorized
users:
# Log in to the server. This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://example.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p http://example.com/interesting/article.php
If the server is using session cookies to track user authentication, the above will not work because --save-cookies will not save them (and neither
will browsers) and the cookies.txt file will be empty. In that case use --keep-session-cookies along with --save-cookies to force saving of session
cookies.