IT story

온라인 파일 / 폴더 목록에 나타나는 모든 파일 및 하위 디렉토리와 함께 HTTP 디렉토리를 다운로드하는 방법은 무엇입니까?

hot-time 2020. 6. 4. 08:12
반응형

온라인 파일 / 폴더 목록에 나타나는 모든 파일 및 하위 디렉토리와 함께 HTTP 디렉토리를 다운로드하는 방법은 무엇입니까?


액세스 할 수있는 온라인 HTTP 디렉토리가 있습니다. 를 통해 모든 하위 디렉토리와 파일을 다운로드하려고했습니다 wget. 그러나 문제는 wget하위 index.html디렉토리를 다운로드 할 때 파일 자체를 다운로드하지 않고 해당 디렉토리의 파일 목록이 포함 된 파일을 다운로드한다는 것입니다.

깊이 제한없이 하위 디렉토리와 파일을 다운로드하는 방법이 있습니까 (다운로드하려는 디렉토리가 컴퓨터로 복사하려는 폴더 인 것처럼).

온라인 HTTP 디렉토리


해결책:

wget -r -np -nH --cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

설명:

  • ddd 디렉토리의 모든 파일과 하위 폴더를 다운로드합니다.
  • -r : 재귀 적으로
  • -np: ccc /… 와 같은 상위 디렉토리로 이동하지 않음
  • -nH : 파일을 호스트 이름 폴더에 저장하지 않음
  • --cut-dirs=3: 그러나 처음 3 개의 폴더 aaa , bbb , ccc 를 생략 하여 ddd저장
  • -R index.html: index.html 파일 제외

참조 : http://bmwieczorek.wordpress.com/2008/10/01/wget-recursively-download-all-files-from-certain-directory-listed-by-apache/


VisualWGet을 사용 하는이 게시물 덕분 에이 기능을 사용할 수있었습니다 . 그것은 나를 위해 잘 작동했습니다. 중요한 부분은 깃발 을 확인하는 것 같습니다 (이미지 참조).-recursive

또한 -no-parent플래그가 중요 하다는 것을 알았 으므로 모든 것을 다운로드하려고 시도합니다.

여기에 이미지 설명을 입력하십시오 여기에 이미지 설명을 입력하십시오


wget -r -np -nH --cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

에서 man wget

'-r' '--recursive' 재귀 검색을 켭니다. 자세한 내용은 재귀 다운로드를 참조하십시오. 기본 최대 깊이는 5입니다.

‘-np’ ‘--no-parent’ Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded. See Directory-Based Limits, for more details.

‘-nH’ ‘--no-host-directories’ Disable generation of host-prefixed directories. By default, invoking Wget with ‘-r http://fly.srk.fer.hr/’ will create a structure of directories beginning with fly.srk.fer.hr/. This option disables such behavior.

‘--cut-dirs=number’ Ignore number directory components. This is useful for getting a fine-grained control over the directory where recursive retrieval will be saved.

Take, for example, the directory at ‘ftp://ftp.xemacs.org/pub/xemacs/’. If you retrieve it with ‘-r’, it will be saved locally under ftp.xemacs.org/pub/xemacs/. While the ‘-nH’ option can remove the ftp.xemacs.org/ part, you are still stuck with pub/xemacs. This is where ‘--cut-dirs’ comes in handy; it makes Wget not “see” number remote directory components. Here are several examples of how ‘--cut-dirs’ option works.

No options -> ftp.xemacs.org/pub/xemacs/ -nH -> pub/xemacs/ -nH --cut-dirs=1 -> xemacs/ -nH --cut-dirs=2 -> .

--cut-dirs=1 -> ftp.xemacs.org/xemacs/ ... If you just want to get rid of the directory structure, this option is similar to a combination of ‘-nd’ and ‘-P’. However, unlike ‘-nd’, ‘--cut-dirs’ does not lose with subdirectories—for instance, with ‘-nH --cut-dirs=1’, a beta/ subdirectory will be placed to xemacs/beta, as one would expect.


wget is an invaluable resource and something I use myself. However sometimes there are characters in the address that wget identifies as syntax errors. I'm sure there is a fix for that, but as this question did not ask specifically about wget I thought I would offer an alternative for those people who will undoubtedly stumble upon this page looking for a quick fix with no learning curve required.

There are a few browser extensions that can do this, but most require installing download managers, which aren't always free, tend to be an eyesore, and use a lot of resources. Heres one that has none of these drawbacks:

"Download Master" is an extension for Google Chrome that works great for downloading from directories. You can choose to filter which file-types to download, or download the entire directory.

https://chrome.google.com/webstore/detail/download-master/dljdacfojgikogldjffnkdcielnklkce

For an up-to-date feature list and other information, visit the project page on the developer's blog:

http://monadownloadmaster.blogspot.com/


No Software or Plugin required!

(only usable if you don't need recursive deptch)

Use bookmarklet. Drag this link in bookmarks, then edit and paste this code:

(function(){ var arr=[], l=document.links; var ext=prompt("select extension for download (all links containing that, will be downloaded.", ".mp3"); for(var i=0; i<l.length; i++) { if(l[i].href.indexOf(ext) !== false){ l[i].setAttribute("download",l[i].text); l[i].click(); } } })();

and go on page (from where you want to download files), and click that bookmarklet.


You can use this Firefox addon to download all files in HTTP Directory.

https://addons.mozilla.org/en-US/firefox/addon/http-directory-downloader/


wget generally works in this way, but some sites may have problems and it may create too many unnecessary html files. In order to make this work easier and to prevent unnecessary file creation, I am sharing my getwebfolder script, which is the first linux script I wrote for myself. This script downloads all content of a web folder entered as parameter.

하나 이상의 파일이 포함 된 wget으로 열린 웹 폴더를 다운로드하려고하면 wget은 index.html이라는 파일을 다운로드합니다. 이 파일에는 웹 폴더의 파일 목록이 포함되어 있습니다. 내 스크립트는 index.html 파일로 작성된 파일 이름을 웹 주소로 변환하고 wget으로 명확하게 다운로드합니다.

Ubuntu 18.04 및 Kali Linux에서 테스트되었으며 다른 배포판에서도 작동 할 수 있습니다.

사용법 :

  • 아래에 제공된 zip 파일에서 getwebfolder 파일을 추출하십시오.

  • chmod +x getwebfolder (처음 만)

  • ./getwebfolder webfolder_URL

와 같은 ./getwebfolder http://example.com/example_folder/

다운로드 링크

블로그 세부 사항

참고 URL : https://stackoverflow.com/questions/23446635/how-to-download-http-directory-with-all-files-and-sub-directories-as-they-appear

반응형