mirror of
https://github.com/bin456789/reinstall.git
synced 2026-02-21 02:17:49 +08:00
windows: 查找到的链接是 / 开头时,补全域名
This commit is contained in:
parent
4cf8e81fc7
commit
81081873df
17
reinstall.sh
17
reinstall.sh
@ -305,6 +305,10 @@ get_host_by_url() {
|
||||
cut -d/ -f3 <<<$1
|
||||
}
|
||||
|
||||
get_scheme_and_host_by_url() {
|
||||
cut -d/ -f1-3 <<<$1
|
||||
}
|
||||
|
||||
get_function() {
|
||||
declare -f "$1"
|
||||
}
|
||||
@ -1095,10 +1099,17 @@ get_windows_iso_link() {
|
||||
if [ -n "$label_msdl" ]; then
|
||||
iso=$(curl -L "$page_url" | grep -ioP 'https://[^ ]+?#[0-9]+' | head -1 | grep .)
|
||||
else
|
||||
http_to_host=$(get_scheme_and_host_by_url "$page_url")
|
||||
http_to_current_dir=$(dirname "$page_url")
|
||||
curl -L "$page_url" |
|
||||
tr -d '\n' | sed -e 's,<a ,\n<a ,g' -e 's,</a>,</a>\n,g' | # 使每个 <a></a> 占一行
|
||||
grep -Ei '\.(iso|img)</a>$' | # 找出是 iso 或 img 的行
|
||||
sed -E 's,<a href="?([^" ]+)"?.+>(.+)</a>,\2 \1,' >$tmp/win.list # 提取文件名和链接
|
||||
tr -d '\n' | sed -e 's,<a ,\n<a ,g' -e 's,</a>,</a>\n,g' | # 使每个 <a></a> 占一行
|
||||
grep -Ei '\.(iso|img)</a>$' | # 找出是 iso 或 img 的行
|
||||
# 提取文件名和链接
|
||||
# 如果链接是 / 开头,则补全域名
|
||||
# 如果链接非 https:// 开头,则补全域名和目录
|
||||
sed -E -e 's,<a href="?([^" ]+)"?.+>(.+)</a>,\2 \1,' \
|
||||
-e "s, (/), $http_to_host\1," |
|
||||
awk '{if ($2 !~ /^https?:\/\//) $2 = "'$http_to_current_dir/'" $2; print}' >$tmp/win.list
|
||||
|
||||
# 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的
|
||||
# 例如查找 windows 10 iot enterprise,会得到
|
||||
|
||||
Loading…
Reference in New Issue
Block a user