#!/bin/bash #define proxy_ip #define proxy_port #define target_url #define proxy #define result #define fine_place target_url='http://www.bdsz.com.cn/'; fine_place=$2; if test -e $fine_place; then rm -f $fine_place; fi; if test ! -e $fine_place; then touch $fine_place; fi; cat $1 | while read line do proxy_ip=$(echo $line|awk '{print $1}' ); proxy_port=$(echo $line|awk '{print $2}'); result=0; proxy=`echo $proxy_ip:$proxy_port`; result=$(curl -x $proxy $target_url -m 5 --connect-timeout 5 -o /dev/null -s -w %{http_code} ); if (("$result"=="200")); then echo $proxy_ip $proxy_port >> $fine_place fi done exit 0;
用法:脚本名 读入文件名 输出文件名
读入文件格式:每行有两列,第一列为proxy的ip,第二列为proxy的port