Как скачать список файлов с файлового сервера?

32267
BinaryMisfit

Как бы мне загрузить список файлов с файлового сервера, например, http://www.apache.org/dist/httpd/binaries/ ?

Я полагаю, я мог бы использовать wget, но затем он пытается получить все ссылки и HTML-файл. Есть ли лучший инструмент для достижения этой цели?

9
просто чтобы уточнить ваш вопрос: вы просто хотите список файлов, которые можно загрузить с сервера, а не сами файлы (пока)? akira 14 лет назад 0
Каким образом команда типа `wget --no-verbose --spider --no-directoryies --recursive --level = 2 http: // www.apache.org / dist / httpd / binaries /` не работает для ты? Если бы вы могли быть более конкретными, это может помочь DaveParillo 14 лет назад 0

3 ответа на вопрос

12
John T

Вы можете указать, какие расширения файлов wgetбудут загружаться при сканировании страниц:

wget -r -A zip,rpm,tar.gz www.site.com/startpage.html 

это будет выполнять рекурсивный поиск и загружать только файлы с .zip, .rpmи .tar.gzрасширений.

7
akira

Предположим, вы действительно хотите получить список файлов на сервере, не загружая их (пока):

%> wget -r -np --spider http://www.apache.org/dist/httpd/binaries/ 2> & 1 | awk -f filter.awk | уник

в то время как «filter.awk» выглядит так

/^--.*-- http: \ / \ /.* [^ \ /] $ /  / ^ Длина: [[: digit:]] + /  

тогда вам, возможно, придется отфильтровать некоторые записи, такие как

"http://www.apache.org/dist/httpd/binaries/?C=N;O=D" 
0
Udit Desai

Ref: http://blog.incognitech.in/download-files-from-apache-server-listing-directory/

You can use following command:

wget --execute="robots = off" --mirror --convert-links --no-parent --wait=5 <website-url> 

Explanation with each options

  • wget: Simple Command to make CURL request and download remote files to our local machine.
  • --execute="robots = off": This will ignore robots.txt file while crawling through pages. It is helpful if you're not getting all of the files.
  • --mirror: This option will basically mirror the directory structure for the given URL. It's a shortcut for -N -r -l inf --no-remove-listing which means:
    • -N: don't re-retrieve files unless newer than local
    • -r: specify recursive download
    • -l inf: maximum recursion depth (inf or 0 for infinite)
    • --no-remove-listing: don't remove '.listing' files
  • --convert-links: make links in downloaded HTML or CSS point to local files
  • --no-parent: don't ascend to the parent directory
  • --wait=5: wait 5 seconds between retrievals. So that we don't thrash the server.
  • <website-url>: This is the website url from where to download the files.

Happy Downloading :smiley:

Похожие вопросы