구성 파일을 저장하는 웹 디렉토리가 있습니다. wget을 사용하여 해당 파일을 가져 와서 현재 구조를 유지하고 싶습니다. 예를 들어, 원격 디렉토리는 다음과 같습니다.
http://mysite.com/configs/.vim/
.vim은 여러 파일과 디렉토리를 보유합니다. wget을 사용하여 클라이언트에서 복제하고 싶습니다. 이 작업을 수행하기 위해 wget 플래그의 올바른 콤보를 찾을 수 없습니다. 어떤 아이디어?
답변
당신은 통과해야 -np
/ --no-parent
에 옵션을 wget
(에 추가 -r
/ --recursive
물론), 그렇지 않으면 상위 디렉토리에 내 사이트에 디렉토리 인덱스에있는 링크를 따릅니다. 따라서 명령은 다음과 같습니다.
wget --recursive --no-parent http://example.com/configs/.vim/
자동 생성 된 index.html
파일을 다운로드하지 않으려면 -R
/ --reject
옵션을 사용하십시오 .
wget -r -np -R "index.html*" http://example.com/configs/.vim/
답변
디렉토리를 재귀 적으로 다운로드하려면 index.html * 파일을 거부하고 호스트 이름, 상위 디렉토리 및 전체 디렉토리 구조없이 다운로드하십시오.
wget -r -nH --cut-dirs=2 --no-parent --reject="index.html*" http://mysite.com/dir1/dir2/data
답변
비슷한 문제가있는 다른 사람. Wget follow robots.txt
는 사이트를 가져 오지 못할 수 있습니다. 걱정할 필요가 없습니다.
wget -e robots=off http://www.example.com/
http://www.gnu.org/software/wget/manual/html_node/Robot-Exclusion.html
답변
-m (미러) 플래그를 사용해야합니다. 타임 스탬프를 엉망으로 만들지 않고 무기한 반복됩니다.
wget -m http://example.com/configs/.vim/
이 스레드에서 다른 사람들이 언급 한 점을 추가하면 다음과 같습니다.
wget -m -e robots=off --no-parent http://example.com/configs/.vim/
답변
다음은 서버 디렉토리에서 파일을 다운로드하는 데 도움이 된 전체 wget 명령입니다 (무시 robots.txt
).
wget -e robots=off --cut-dirs=3 --user-agent=Mozilla/5.0 --reject="index.html*" --no-parent --recursive --relative --level=1 --no-directories http://www.example.com/archive/example/5.3.0/
답변
--no-parent
도움 이 되지 않으면 --include
옵션을 사용할 수 있습니다 .
디렉토리 구조 :
http://<host>/downloads/good
http://<host>/downloads/bad
그리고 디렉토리 를 다운로드 downloads/good
하지 않고 다운로드하려고합니다 downloads/bad
.
wget --include downloads/good --mirror --execute robots=off --no-host-directories --cut-dirs=1 --reject="index.html*" --continue http://<host>/downloads/good
답변
wget -r http://mysite.com/configs/.vim/
나를 위해 작동합니다.
아마도 방해하는 .wgetrc가 있습니까?
