p-proxy v1.0.cmd

作者:vkill


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: p-proxy.cmd -V1.0 -by:vkill -2006/12/25
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
:000
cls
call :help_
echo (以后可以/?查看帮助)
echo.
set var=
set/p var= 下次运行是否继续显示此帮助[Y/N]:
if /i %var%*==* goto 000
if /i %var%*==Y* goto start
if /i %var%*==N* goto 写第一行
goto 000
:写第一行
cd.>>%0 ||(echo 你没有本目录的写入权限&pause>nul&goto :eof)
for /f "tokens=*" %%a in ('echo goto start^&more^<%0') do (
if not defined vkill (>%0 echo %%a&set vkill=vkill) else >>%0 echo %%a
)
cls
echo 跳过帮助已设置完毕,重新运行本程序生效,任意键退出
pause>nul
goto :eof
:start
@echo off
if %~1*==/?* call :help_
if %~1*==-?* call :help_
if %~1*==/h* call :help_
if %~1*==-h* call :help_
:conf
::是否需要网络支持
set "net_on=y"
set "search_url=http://www.baidu.com/s?wd="
set "search_关键字=代理ip"
set "tools_url=http://www.vkill.net/tools/"
set "tools_name=wget.exe;sed.exe;gawk.exe;HtoX32c.exe"
::下载baidu搜索到前10个页面
set "top=10"
set "temp=test.tx"
cls
:test
call :del_
if not %temp%*==* (cd.>>%0 ||(echo 你没有本目录的写入权限&pause>nul&goto :eof))
if %net_on%*==y* (ping -n 1 www.baidu.com>nul 2>nul||(echo 网络不通,请先检查网络&pause>nul&goto :eof))
title [1/4]依赖文件完整性检查开始 by:vkill
if not "%tools_name%*"=="*" (
for %%? in (%tools_name%) do (
if *%%~$PATH:?==* if not exist %%? (
echo 程序所依赖文件%%?缺失,已自动开始下载
if not exist iget.vbs call :iget.vbs_
iget.vbs "%tools_url%%%?" "%%?"
echo 文件%%?下载完毕
)
)
)
::参数-v时开始验证ip-port.txt文件中的地址
if /i %~1*==-v* goto validate
title [2/4]获取代理地址开始 by:vkill
cls
echo 请稍候......
:down_index
wget -q -O "a%temp%" "%search_url%%search_关键字%"
:find_top
sed -n "/<DIV id=ScriptDiv><\/DIV>/,/<br clear=all>/p" a%temp%|sed "s/this.href,/\n/g"|sed "s/.*)\x22 href=\x22//;s/\x22 target=\x22.*//"|sed "/^http:\/\//!d"|more>b%temp%
:down_top
md html>nul 2>nul
for /f "tokens=*" %%? in (b%temp%) do (wget -q -t 1 --directory-prefix=html "%%?")
:htm2txt
HtoX32c.exe /ip html\*.*>c%temp%
:find_ip-port
sed -n "/^:awk_conf$/,/^::end awk_conf$/p" %0|sed "1d;$d"|more>awk_conf
gawk "/[1-9]*\.[1-9]*\.[0-9]*\.[0-9]/" c%temp%|gawk -f awk_conf|more>d%temp%
:validate
title [3/4]验证代理地址开始 by:vkill
cls
if /i "%~1*"=="-v*" (set var=ip-port.txt) else (set var=d%temp%)
for /f "eol=; tokens=1,2 delims= " %%a in (%var%) do (
set/p=正在验证%%a:%%b <nul
wget -q -T 3 -t 1 -e "http_proxy=%%a:%%b" http://www.baidu.com -O - >nul 2>nul &&(echo %%a:%%b>>e%temp%&set/p=→ok <nul)
echo.
)
title [4/4]设置、修改、删除代理 by:vkill
cls
findstr . e%temp%>nul 2>nul ||(echo 没有有效的代理&pause>nul&goto :end)
findstr /N . e%temp%>proxy.txt
call :del_
for /f "tokens=*" %%? in ('sed -n $= proxy.txt') do (set "max_n=%%?")
for /f "tokens=3 delims= " %%? in ('@reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"^|findstr "Proxyserver"') do (if not "%%?*"=="*" (set y_proxy=%%?) else (set y_proxy=空))
for /f "tokens=3 delims= " %%? in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"^|findstr "ProxyEnable"') do (if "%%?*"=="0x1*" (set y_on=打开) else (set y_on=关闭))
:liebiao
cls
echo.
echo 当前代理设置如下
echo 代理%y_on% 地址%y_proxy%
echo ________________________________________________________________________________
echo 检测完有效的代理列表如下(行号 代理ip:proxy),共%max_n%个代理有效
echo.
more<proxy.txt
echo ________________________________________________________________________________
set xz=
set /p xz= 请输入你要设置为当前ie代理的行号:
if "%xz%"=="" echo 无效动作 & pause && goto liebiao
echo %xz%|findstr "^[0-9]" ||echo 无效动作 & pause && goto liebiao
if not %xz% lss %max_n% (echo 无效动作 & pause && goto liebiao)
:xz_ok
for /f "tokens=2,3 delims=:" %%a in ('type proxy.txt^|findstr /B "%xz%:") do (set proxy_ip=%%a:%%b)
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v Proxyserver /d %proxy_ip% /f
:hxz
cls
echo ________________________________________________________________________________
echo 你已经成功将%proxy_ip%设置为当前ie的代理地址
echo.
echo 重新打开ie生效
echo.
echo a 重新选择 ; b 取消当前代理设置 ; c 保存退出
echo ________________________________________________________________________________
set hxz=
set /p hxz= 请输入操作代码:
if "%hxz%"=="" echo 无效动作 & pause && goto hxz
if "%hxz%"=="a" goto liebiao
if "%hxz%"=="c" goto :eof
if "%hxz%"=="b" goto quxiao
goto hxz
:quxiao
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
@reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v Proxyserver /f
echo 取消当前代理设置成功,按任意键退出&pause>nul
:end
call :del_
goto :eof
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
::所有call
:help_
title help
echo ________________________________________________________________________________
echo 用途:
echo 代理查找、设置、验证器 by:vkill
echo.
echo 使用方法:
echo 1.直接运行本程序,将自动查找到"baidu"关键词"代理ip"前10位的页面中所有代理的
echo 地址并验证其可用性,然后可以设置、修改、删除当前设置
echo 2.加-v参数将验证ip-port.txt文件中所有代理地址其可用性,然后可以设置、修改、
echo 删除当前设置
echo.
echo 程序依赖文件:(详细用法http://www.vkill.net/tools.html页面下载相应文件)
echo 1.wget.exe 1.10.2 验证代理,下载网页
echo 2.sed.exe 4.0.7x 文本文字处理
echo 3.gawk.exe 3.1.5 文本文字处理
echo 4.HtoX32c 1.7.3 htm2txt
echo ________________________________________________________________________________
goto :eof
:del_
del /f/q ?%temp%>nul 2>nul
del /f/q html\*.*>nul 2>nul
del /f/q iget.vbs>nul 2>nul
del /f/q awk_conf>nul 2>nul
goto :eof
:iget.vbs_
>iget.vbs echo x=LCase(WScript.Arguments(1))
>>iget.vbs echo y=LCase(WScript.Arguments(0))
>>iget.vbs echo Set xPost=CreateObject("Microsoft.XMLHTTP")
>>iget.vbs echo xPost.Open "GET",y,0
>>iget.vbs echo xPost.Send()
>>iget.vbs echo Set sGet=CreateObject("ADODB.Stream")
>>iget.vbs echo sGet.Mode=3
>>iget.vbs echo sGet.Type=1
>>iget.vbs echo sGet.Open()
>>iget.vbs echo sGet.Write(xPost.responseBody)
>>iget.vbs echo sGet.SaveToFile x,2
goto :eof
:awk_conf
{if($1~/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/ && $1!="0.0.0.0" && $2>0 && $2<65535 && $2~/^[0-9]*$/)
print $1,$2}
{if($2~/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/ && $2!="0.0.0.0" && $3>0 && $3<65535 && $3~/^[0-9]*$/)
print $2,$3}
::end awk_conf
goto :eof

相关日志

楼被抢了 4 层了... 抢座Rss 2.0或者 Trackback

  • vkill

    :smile:
    thanks

  • 鬼仔

    no thanks :lol:

  • vkill

    过几天完善下,增加几个参数,可直接命令行验证一个指定代理,呵呵~

  • 鬼仔

    已经看到你的新版了,又发了一篇

发表评论