0
使用curl我正在提取%{http_code}%{size_header}%{redirect_url},它效果很好,但我也想將網站標題添加到Bash響應中。如何在bash中從網站提取http代碼,大小標題和標題?
usage: check-website.sh website-list.txt
#!/bin/bash
FILE="$1"
while read LINE; do
curl -H 'Cache-Control: no-cache' -i -s -k -o /dev/null --silent --max-time 2 --write-out '%{http_code} %{size_header} %{redirect_url}' "$LINE"
echo " $LINE"
done < ${FILE}
我一直在尋找與此curl命令提取標題:
curl -s example.com | grep -o "<title>[^<]*" | cut -d'>' -f2-
,但我不知道如何做到這一點,爲了得到像在bash輸出:
%{http_code} %{size_header} %{redirect_url} $website_title
任何人都可以幫我加入標題嗎?
謝謝,這很好。我很接近 :) – pancho