
다음은 한 디렉터리에 있는 tree 명령의 출력입니다.
.
|-- asdf.txt
|-- asd.txt
|-- fabc
| |-- fbca
| `-- file1.txt
|-- fldr1
|-- fldr2
| `-- index.html
|-- fldr3
| |-- cap.txt
| `-- f01
`-- out.txt
6 directories, 6 files
이 디렉토리에서 로컬 http 서버를 시작합니다. 다음으로 다음 명령을 실행합니다.
wget -r -nv --spider --no-parent http://localhost:3000 -o -
...그리고 다음과 같은 출력을 얻습니다.
2017-01-02 20:07:24 URL:http://localhost:3000/ [1580] -> "localhost:3000/index.html" [1]
http://localhost:3000/robots.txt:
2017-01-02 20:07:24 ERROR 404: Not Found.
2017-01-02 20:07:24 URL:http://localhost:3000/fabc/ [897] -> "localhost:3000/fabc/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr1/ [536] -> "localhost:3000/fldr1/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr2/ [0/0] -> "localhost:3000/fldr2/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr3/ [896] -> "localhost:3000/fldr3/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/asd.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL: http://localhost:3000/asdf.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL: http://localhost:3000/out.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL:http://localhost:3000/fabc/fbca/ [548] -> "localhost:3000/fabc/fbca/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/fabc/file1.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL:http://localhost:3000/fldr3/f01/ [548] -> "localhost:3000/fldr3/f01/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/fldr3/cap.txt 200 OK
unlink: No such file or directory
Found no broken links.
FINISHED --2017-01-02 20:07:24--
Total wall clock time: 0.3s
Downloaded: 7 files, 4.9K in 0s (43.4 MB/s)
- wget은 항상 찾도록 작성되어 있습니까
index.html
? 이것을 비활성화할 수 있나요? - 1580, 536, 0/0 등과 같은 숫자는 무엇입니까?
- 왜 그렇게 말합니까
unlink: No such file or directory
?
답변1
옵션을 사용하여 파일을 건너뛸 수 있습니다
--reject
(와일드카드도 허용).wget --reject index.html
그러나 당신은 이것을 하고 싶지 않습니다. 와 함께 wget을 사용할 때 -r
어떻게든 디렉토리 내부의 파일 목록을 가져와야 합니다. 따라서 wget은 index.html 파일을 요청하고 이 디렉토리의 다른 파일에 대한 경로를 얻기 위해 내용을 구문 분석합니다. 폴더에 index.html 파일이 없으면 웹 서버는 일반적으로 wget에 대해 해당 파일을 생성합니다. 이 파일에는 디렉토리 목록이 포함됩니다. 이 목록 파일 생성은 웹서버에서 활성화되어야 합니다. 그렇지 않으면 wget은 HTTP 404 응답을 수신하고 재귀 다운로드에 실패합니다.
- 파일 크기(바이트)입니다.
- 이는 파일을 제거할 수 없음을 의미합니다(아마도 처음에 생성되지 않았기 때문일 것입니다). wget으로 다운로드한 디렉토리에 대한 쓰기 권한이 있습니까?
편집하다:wget 다운로드를 테스트한 후 --spider
연결 --recursive
해제 오류를 재현했습니다. wget은 파일에 다른 리소스에 대한 링크가 포함될 수 있는지 확인하기 위해 콘텐츠 유형의 응답을 사용하는 것 같습니다. 콘텐츠 유형 테스트가 실패하고 파일이 다운로드되지 않으면 wget은 마치 다운로드된 것처럼 임시 파일을 제거하려고 시도합니다(이는 로 wget을 다시 실행할 때 분명합니다 --debug
. 명확하게 표시됩니다 Removing file due to --spider in recursive_retrieve():
). wget에서 버그를 발견한 것 같습니다.