botaniQQQ
@botaniQQQ
Q

Как скачивать файлы через Wget без @ в названии?

Привет.

Собственно вот в чем вопрос, когда скачиваешь весь сайт, то некоторые файлы имеют название:
example.com/css/style.css?3

Wget скачивает этот файл в папку /css, однако ? заменяет на @ - /css/style.css@3

Хотелось бы получать файлы со стандартным названием /css/style.css
  • Вопрос задан
  • 593 просмотра
Решения вопроса 2
BuriK666
@BuriK666
Компьютерный псих

-E
--adjust-extension
If a file of type application/xhtml+xml or text/html is downloaded and the URL does not end with the regexp \.[Hh][Tt][Mm][Ll]?, this option will cause the suffix .html to be appended to the local filename. This is
useful, for instance, when you're mirroring a remote site that uses .asp pages, but you want the mirrored pages to be viewable on your stock Apache server. Another good use for this is when you're downloading CGI-
generated materials. A URL like site.com/article.cgi?25 will be saved as article.cgi?25.html.

Note that filenames changed in this way will be re-downloaded every time you re-mirror a site, because Wget can't tell that the local X.html file corresponds to remote URL X (since it doesn't yet know that the URL produces
output of type text/html or application/xhtml+xml.

As of version 1.12, Wget will also ensure that any downloaded files of type text/css end in the suffix .css, and the option was renamed from --html-extension, to better reflect its new behavior. The old option name is
still acceptable, but should now be considered deprecated.

At some point in the future, this option may well be expanded to include suffixes for other types of content, including content types that are not parsed by Wget.


ну или для каждого запроса указывать имя файла вручную
-O file
--output-document=file
Ответ написан
botaniQQQ
@botaniQQQ Автор вопроса
Q
В общем решение такое. В текстовом редакторе массово заменяем все названия по регулярному выражению:

@[0-9a-zA-Z]{1,5}\)
на
)

@[0-9a-zA-Z]{1,5}"\)
на
")

Затем исполняем массовую переименовку файлов в папке сайта:

#!/bin/bash

for i in `find . -depth -type d`
do
    cd "${i}"
    for j in *.*@*; do
        IFS='@' read -r -a NAME <<< "${j}"
        mv "${j}" "${NAME[0]}"
    done
    cd -
done
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 17:06
15000 руб./за проект
19 апр. 2024, в 16:53
1000 руб./за проект
19 апр. 2024, в 16:45
5000 руб./за проект