-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrab_proxy.sh
48 lines (40 loc) · 1.01 KB
/
grab_proxy.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
#!/bin/bash
#get proxy list
declare proxyListFile="proxy.txt"
declare tmpFile=`mktemp`
declare url
declare line
declare times
declare ip
declare port
declare i
declare j
declare mod
function quit() {
rm -f $tmpFile
exit "$1"
}
echo "get proxy list... please wait..."
if [ -r "$proxyListFile" ]
then
rm -f $proxyListFile
fi
touch $proxyListFile
for url in " http://www.youdaili.cn/Daili/guonei/2371.html " \
" http://www.youdaili.cn/Daili/guonei/2365.html " \
" http://www.youdaili.cn/Daili/guonei/2355.html " \
" http://www.youdaili.cn/Daili/guonei/2360.html "
do
if GET "$url" > $tmpFile
then
grep -oE '^.*.*$' "$tmpFile" | grep -Eo "([0-9]+)(\.[0-9]+){3}:([0-9]+)" \
| sort -n | uniq | awk -F: '{ printf("%-15s %s \n",$1,$2); }' >> $proxyListFile
else
exec 1>&2
echo "error: get proxy list fail! chech the url:$url or the network"
quit 1
fi
done
echo "done. total `cat $proxyListFile | wc -l` proxy"
quit 0
#exit