-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path流量杀手.sh
52 lines (43 loc) · 1.31 KB
/
流量杀手.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
## 主要变量
### User-Agent
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586"
### 目标下载连接
DownloadLink=
### 间隔时间,单位秒
waitTime=1
## Generate split line / 生成分割线
function print_x_axis(){
local Line= Title= Bytes= Xlength=
Title="$*"
Line='-'
if [ -n "${Title}" ]; then
Bytes=$(echo "${Title}"|wc -c)
else
Bytes=1
fi
Xlength=$(( $(stty size|awk '{print $2}') - ${Bytes} ))
printf '%s ' "${Title}"
printf "%${Xlength}s\n" "${Line}"|sed "s/ /${Line}/g"
}
## 打印基本信息
print_x_axis
echo UA = ${UA}
echo Link = ${DownloadLink}
print_x_axis
## 循环下载
i=0
all_size_download=0
### 循环次数,需要的循环次数-1,例如需要循环1000次,即填999就行
while ((${i}<=999))
do
let "i++"
#curl --user-agent "${UA}" -o /dev/null ${DownloadLink}
new_size_download=$(curl --user-agent "${UA}" -o /dev/null ${DownloadLink} --write-out @size_download)
all_size_download=$((${all_size_download}+${new_size_download}))
print_x_axis
echo "已完成第 ${i} 次"
echo "共计下载量:" $((${all_size_download}/1024/1024)) "MB"
sleep ${waitTime}
print_x_axis
done