批量探测URL的可达性

经常在网站上加一大堆外链, 时间长了,很多外链已经不可达了,如何检验是个头痛的问题。下面的脚本便是止痛良药。

while read -r url; do
    curl -sL -w "%{http_code} %{url_effective}\n" "$url" -o /dev/null
done <<EOF
http://example.com/
https://itcool.fun/
http://bixuebihui.com/
https://qsn.so/
http://www.google.com/
https://qsn.so/index.php?user-app-login
http://以及其他的你要检查的.url/
EOF

将以上片断保存为 ping_url.sh

$ chmod u+x ping_url.sh

执行

$ ping_url.sh

便可以看到很可爱的输出

200 http://example.com/
000 https://itcool.fun/
403 http://bixuebihui.com/
000 https://qsn.so/
000 http://www.google.com/
200 https://qsn.so/index.php?user...
000 http://以及其他的你要检查的.url/

那些有问题的页面会输出400以上的状态码(status code).

也有一些返回 000不知为什么, 欢迎留言告诉我。

curl是个好工具!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值