一个获取代理的脚本

fog posted @ 2008年8月26日 00:42 in 生活相关 with tags life linux , 2705 阅读

曾经在linuxsir.org上看到过一个获取代理的脚本,觉得挺实用的,于是拿来自己改了改,效果还不错,贴出来分享。

#
# This script is used to get free http proxies from
# www.cybersyndrome.net
#
# fog, Sun Jul 23 00:17:54 2006
#

#!/bin/bash

red="\033[31m"
green="\033[32m"
yellow="\033[33m"
end="\033[0m"

test_page="www.google.cn"
timeout=20

if [ "$#" = 0 ]
then
    echo -e ${yellow}Using "$test_page" to test ...${end}
    echo
else
    timeout=$1
    if [ "$#" = 2 ]
    then
        test_page=$2
    fi
fi

proxy_page="http://www.cybersyndrome.net/pla4.html"
echo -n -e ${yellow}"Getting latest proxy file and abstract proxy ..."${end}
PROXYS=`wget --quiet -T 20 -t 1 -O - $proxy_page |grep '<li>'|sed -e 's/<[^<>]\{1,\}class=\"[^BCA]\">[^<>]\{1,\}<\/a>//g'|sed -e 's/<[^<>]\{1,\}>/ /g'`

if [ "$?" = 0 ]
then
    echo -e ${green}OK${end}
else
    echo -e ${red}Failed${end}
    exit 1
fi


WGET="wget --quiet --cache=off -T $timeout -t 1 -w 0 -O /dev/null $test_page"
PROXY=""

for proxy in $PROXYS ; do
    export http_proxy="http://$proxy"
#    echo "$http_proxy"
    /usr/bin/time -o /tmp/proxytimer_$proxy.txt -f %e $WGET &
done

echo Wait $timeout+2 seconds...
sleep $timeout
sleep 2

for proxy in $PROXYS;do
#    echo "$proxy"
    grep -q "status" /tmp/proxytimer_$proxy.txt || cat /tmp/proxytimer_$proxy.txt | sed -e "s/$/, $proxy/" >> /tmp/proxytimer_total
#    M=`grep -q "status" /tmp/proxytimer_$proxy.txt || cat /tmp/proxytimer_$proxy.txt | sed -e "s/$/, $proxy/" `
#    echo "<$M>"
#    echo $M >> /tmp/proxytimer_total
done

echo -e ${yellow}"Top 10 proxies in this run:"${end}
cat /tmp/proxytimer_total |grep -e "^[0-9]" |sort -n -t',' -k1| head -n10
rm -f /tmp/proxytimer_*

Avatar_small
ch 说:
2023年8月07日 03:34

That seems, by all accounts, to be fantastic anyway i am still not very beyond any doubt that I like it. At any rate will look significantly more into it and choose by and by! 먹튀검증업체

Avatar_small
ch 说:
2023年8月09日 04:26

pleasant bLog! its intriguing. much obliged to you for sharing.... Ac repair las vegas

Avatar_small
ch 说:
2023年8月28日 06:11

Hey what a splendid post I have go over and trust me I have been looking out for this comparative sort of post for recent week and scarcely ran over this. Much thanks and will search for more postings from you. 10bit

Avatar_small
ch 说:
2023年9月03日 07:13

Great artcile, however it would be better if in future you can share more about this subject. Continue posting. 먹튀검증업체

Avatar_small
ch 说:
2023年10月04日 03:32

Hey what a splendid post I have go over and trust me I have been looking out for this comparative sort of post for recent week and scarcely ran over this. Much thanks and will search for more postings from you. 먹튀검증사이트

Avatar_small
jam 说:
2023年11月01日 21:22

I am not sure where you’re getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for great info I was looking for this info for my mission. Sports leggings


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter