批处理生成简易自动代理脚本(Pac) Posted: 29 May 2012 08:25 PM PDT 自动代理最大的优点就是不妨碍正常浏览,而被屏蔽的网站又可以自定义进行代理访问。几乎一次设置适用终身了。 但是频繁的设置代理地址却是件很麻烦的事情,现在利用批处理配置自动代理脚本,就方便多了。
My_Proxy_Pac.bat
cls&@echo off&color 2f&cd /d %~dp0 :::设置My.Pac路径 Set My_Path=d:\my.pac >%My_Path% Echo function FindProxyForURL(url, host){ >>%My_Path% Echo var proxy = Array(); >>%My_Path% Echo proxy[0] ="PROXY 127.0.0.1:8000"; >>%My_Path% Echo proxy[1] ="PROXY 127.0.0.1:8118"; >>%My_Path% Echo proxy[2] ="PROXY 127.0.0.1:9666"; >>%My_Path% Echo proxy[3] ="PROXY 127.0.0.1:8580"; >>%My_Path% Echo proxy[4] ="PROXY 127.0.0.1:1984"; >>%My_Path% Echo var patterns = new Array( for /f "skip=20" %%a in (%~0) do echo "%%a",>>%My_Path% >>%My_Path% Echo "abcd.com"); >>%My_Path% Echo for (i in patterns) { >>%My_Path% Echo if( url.toLowerCase().indexOf( patterns[i].toLowerCase() ) ^>= 0 ){return proxy[0];}; >>%My_Path% Echo }; >>%My_Path% Echo return "DIRECT"; >>%My_Path% Echo }; goto :eof =========================请在下面输入要代理的url的关键字========================= |
|
|
|
|
My_No_Proxy_Pac.bat cls&@echo off&color 2f&cd /d %~dp0 :::设置My.Pac路径 Set My_Path=d:\my.pac >%My_Path% Echo function FindProxyForURL(url, host){ >>%My_Path% Echo var proxy = Array(); >>%My_Path% Echo proxy[0] ="PROXY 127.0.0.1:8000"; >>%My_Path% Echo proxy[1] ="PROXY 127.0.0.1:8118"; >>%My_Path% Echo proxy[2] ="PROXY 127.0.0.1:9666"; >>%My_Path% Echo proxy[3] ="PROXY 127.0.0.1:8580"; >>%My_Path% Echo proxy[4] ="PROXY 127.0.0.1:1984"; >>%My_Path% Echo var patterns = new Array( for /f "skip=20" %%a in (%~0) do echo "%%a",>>%My_Path% >>%My_Path% Echo ".cn"); >>%My_Path% Echo for(var i = 0; i ^< patterns.length; i++) { >>%My_Path% Echo if(shExpMatch(url.toLowerCase (), "*" + patterns[i].toLowerCase() + "*")){return "DIRECT";}; >>%My_Path% Echo }; >>%My_Path% Echo return proxy[0]; >>%My_Path% Echo }; goto :eof ==============请在下面输入不需要代理的url的关键字=================== 163.com 56.com appspot.com baidu.com baidu.com cat898.com cctv.com china.com douban.com google.com gougou.com ifeng.com is.gd jgxx.com kdnet.net ku6.com live.com mop.com msn.com pcbeta.com qq.com sohu.com sohu.com taobao.com tgbus.com tom.com tudou.com w3.org xinhuanet.com ynet.com youku.com is.gd |
|
|
|
|
用AutoProxy的gfwlist建立适合自己的proxy脚本
有时除了用 Privoxy, 还用了 ipv6 over ipv4 等方式上网,AutoProxy官方的代理脚本有时就显得不太适合自己,今天做了个能按自己需要生成代理脚本的批处理方便自己用.
这里和朋友分享,会批处理的朋友可以自己修改以便适合自己用。不会的朋友只需要根据你的代理软件 修改代码中的" return proxy[0]"改数字就可以了就可以了。
批处理中要用到的Base64.exe和curl.exe软件可以到这里下载:http://www.vkill.net/tools.html
批处理代码: ============================================================================== cls&@echo off&color 2f&echo.&echo 正在下载(AutoProxy gfwList)文件…………&echo ==============================================================================&cd /d %~dp0 :::设置My.Pac路径 Set My_PacPath=d:\my.pac Set My_Path=gfwlist.txt&Set My_Proxy=http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt curl "%My_Proxy%">%My_Path%_tmp.txt :::curl -x 127.0.0.1:8000 "%My_Proxy%">%My_Path%_tmp.txt Base64.exe -d %My_Path%_tmp.txt %My_Path%&echo ============================================================================== for %%a in (! [ google youtube) do Call :取消不用代理的站点 %%a for %%a in (a b) do Call :替换字符串 %%a echo.&echo 正在写入代理脚本(%My_PacPath%)文件………… >%My_PacPath% Echo function FindProxyForURL(url, host){ >>%My_PacPath% Echo var proxy = Array(); >>%My_PacPath% Echo proxy[0] ="PROXY 127.0.0.1:8000"; >>%My_PacPath% Echo proxy[1] ="PROXY 127.0.0.1:8118"; >>%My_PacPath% Echo proxy[2] ="PROXY 127.0.0.1:9666"; >>%My_PacPath% Echo proxy[3] ="PROXY 127.0.0.1:8580"; >>%My_PacPath% Echo proxy[4] ="PROXY 127.0.0.1:1984"; >>%My_PacPath% Echo proxy[5] ="SOCKS 127.0.0.1:9050"; >>%My_PacPath% Echo var patterns = new Array( for /f "skip=50" %%a in (%~0) do echo "%%a",>>%My_PacPath% for /f %%i in (gfwlist.txt) do echo "%%i",>>%My_PacPath% >>%My_PacPath% Echo "a.cc"); >>%My_PacPath% Echo for (i in patterns) { >>%My_PacPath% Echo if(shExpMatch(url.toLowerCase(),"*" + patterns[i].toLowerCase() + "*")){return proxy[0];}; >>%My_PacPath% Echo }; >>%My_PacPath% Echo return "DIRECT"; >>%My_PacPath% Echo }; echo.&&echo 创建[ %My_PacPath% ]代理脚本完成,请按任意键退出!&&pause>nul&exit
:取消不用代理的站点 echo.&echo 正在取消与%1相关的代理的站点 TYPE %My_Path%|FIND /I /V "%1">%My_Path%_tmp.txt move %My_Path%_tmp.txt %My_Path%>nul goto :eof :替换字符串 setlocal enabledelayedexpansion set replaced= if /i "%1"=="a" set replaced=^| if /i "%1"=="b" set replaced=^@ set all= echo.&echo 正在替换 ^%replaced% 字符串 for /f "delims=" %%i in ('type "%My_Path%"') do ( set str=%%i set "str=!str:%replaced%=%all%!" echo !str!>>"%My_Path%"_tmp.txt ) move "%My_Path%"_tmp.txt "%My_Path%" >nul goto :eof
========================请在下面输入要代理的url的关键字========================
|
|
|
|
|
没有评论:
发表评论