代码: 全选
2009-06-03 13:59:55 三 ~/应用/脚本
☎ proxy-CN-pac.pl
WARNING: timestamping does nothing in combination with -O. See the manual
for details.
--2009-06-03 13:59:59-- http://www.proxycn.com/html_proxy/http-1.html
Resolving www.proxycn.com... 221.130.201.146
Connecting to www.proxycn.com|221.130.201.146|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 90835 (89K) [text/html]
Saving to: `STDOUT'
100%[================================================>] 90,835 --.-K/s in 0.1s
2009-06-03 14:00:01 (748 KB/s) - `-' saved [90835/90835]
只取国内的ProxyCN的代理地址,且不丢包的。
--189.112.246.145:8080--20%
--187.4.83.62:8080--0%
proxyCN ="PROXY 187.4.83.62:8080";
2009-06-03 14:00:11 三 ~/应用/脚本
☎ cat ~/.opera/exp-opera.pac
function FindProxyForURL(url, host){
proxyTor ="PROXY localhost:8118";
proxyOpenDNS ="PROXY 208.67.222.222";
proxyOpenDNS1 ="PROXY 208.67.220.220";
proxyCN ="PROXY 187.4.83.62:8080";
///home/exp/.opera/exp-opera.pac
//or http://pac.ipcn.org/thu.pac
//需认证 proxyuser:proxy Password:ipcnsoft
//http://proxy.ipcn.org/
host=host.toLowerCase();
if(
dnsDomainIs(host,"wikipedia.org")
||dnsDomainIs(host,"mediawiki.org")
||dnsDomainIs(host,"wikiquote.org")
||dnsDomainIs(host, ".blogspot.com")
||dnsDomainIs(host, ".googlepages.com")
||dnsDomainIs(host, ".wordpress.com")
||dnsDomainIs(host, ".livejournal.com")
||dnsDomainIs(host, "my.opera.com")
||dnsDomainIs(host, "my.allhabit.com")
)
// return "PROXY 127.0.0.1:8118";
return proxyCN;
else return "DIRECT";
}
2009-06-03 14:00:17 三 ~/应用/脚本
☎ cat proxy-CN-pac.pl
#!/usr/bin/perl
my $C=`wget -N -O - http://www.proxycn.com/html_proxy/http-1.html`;
my @i=$C=~/<TR.*?<\/TR>/gs;
print "只取国内的ProxyCN的代理地址,且不丢包的。\n";
foreach (@i){
if (/>ProxyCN</) {
/clip\(\'(.*?)\'\)/;
$C=$1;
print "--".$1;
(my $re)=split(":",$1); $re=`ping $re -c 5`; $re=~/\b(\d*)% packet loss/;
print "--".$1."%\n";
next if ($1>0);
$C="proxyCN\t\t=\"PROXY\ $C\"\;";
print $C."\n";
last;
}
}
die "没找到适合的代理。\n" if ! $C=~/^proxyCN/;
#`sed "s/^proxyCN.*/proxyCN\t\t=\"PROXY\ ${r[0]}\"\;/" -i "/home/exp/.opera/exp-opera.pac"`;
my $f="/home/exp/.opera/exp-opera.pac";
open (PAC,$f) or die("没有pac文件。\n");
open (PACNEW,">$f-new");
while(<PAC>){
if (! /^proxyCN/){
print PACNEW;
}
else{
print PACNEW $C."\n";
}
}
close(PAC);
close(PACNEW);
rename "$f-new","$f";