Add header and cookie for host 10.1.205.13

This commit is contained in:
leafee98 2023-02-18 17:38:43 +08:00
parent c77294588a
commit 16795b3449

View file

@ -30,6 +30,17 @@ echo auth host: $auth_host
# for wireless, which will be redirected to this location, a "@bistu" is required, # for wireless, which will be redirected to this location, a "@bistu" is required,
if [ "$auth_host" == *"10.1.206.13"* ] ; then if [ "$auth_host" == *"10.1.206.13"* ] ; then
username="${username}@bistu" username="${username}@bistu"
declare -a cookie_opt
declare -a header_opt
cookie_opt+=("--cookie" "program=beijing-information")
cookie_opt+=("--cookie" "md5_login2=$username|$password")
header_opt+=("--header" "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
header_opt+=("--header" "Accept-Language: en-US,zh-CN;q=0.5")
header_opt+=("--header" "Accept-Encoding: gzip, deflate")
header_opt+=("--header" "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0")
fi fi
# Note that the encoding of response is gb2312, so we need to transcode # Note that the encoding of response is gb2312, so we need to transcode
@ -51,6 +62,8 @@ title=$(curl --no-progress-meter --include \
--data-urlencode "user=" \ --data-urlencode "user=" \
--data-urlencode "cmd=" \ --data-urlencode "cmd=" \
--data-urlencode "Login=" \ --data-urlencode "Login=" \
"${cookie_opt[@]}" \
"${header_opt[@]}" \
$auth_host | iconv --from-code=gb2312 --to-code=utf-8 | sed -n -E 's#<title>(.*)</title>#\1#p') $auth_host | iconv --from-code=gb2312 --to-code=utf-8 | sed -n -E 's#<title>(.*)</title>#\1#p')
echo auth result page title: $title echo auth result page title: $title