标题: [数值计算] 批处理如何把web地址转为十进制地址? [打印本页]
作者: youxi01 时间: 2008-2-29 00:28 标题: 批处理如何把web地址转为十进制地址?
web地址如何转为十进制地址?
如本论坛网址:bbs.bathome.net,是否可以把它转化为一个大整数,到时只要输入那个大整数,也可以访问本论坛?
作者: ieutk 时间: 2008-3-1 17:35
- @echo off&setlocal enabledelayedexpansion
-
- title code by ieutk @ bbs.bathome.net
-
- mode con: cols=65 lines=12
-
- color 1b
-
- set "split=4"
-
- set "_split=0"
-
- set "num=0"
-
- :main
-
- cls&echo.&echo.
-
- set input=
-
- set /p input= 请输入WEB地址:
-
- if not defined input goto main
-
- for /f "tokens=4 delims=: " %%a in ('ping /n 1 %input%^|find /i "ping statistics"') do set "ip=%%a"
-
- set "ip=%ip:.= %"
-
- set /a n3=256*256*256,n2=256*256
-
- call :pd
-
- for /f "tokens=1-4 delims= " %%a in ("%ip%") do (
-
- set "ie=%%a"
-
- set /a sc=%%b*n2+%%c*256+%%d
-
- )
-
- set /a fs1=a1*ie,fs2=a2*ie
-
- call set /a fsn=%%fs2:~0,-%split%%%+fs1
-
- call set fs=%fsn%%%fs2:~-%split%%%
-
- call :lh
-
- call set /a zh=%%fs:~-%_split%%%+sc
-
- if not "!zh:~%_split%,1!"=="" (
-
- call set /a _h=%%fs:~0,-%_split%%%+%%zh:~0,-%_split%%%
-
- call set hh=%%_h%%%%zh:~-%_split%%%
-
- ) else (
-
- call set hh=%%fs:~0,-%_split%%%%zh%
-
- )
-
- echo %hh%
-
- echo.&pause&goto :eof
-
-
- :pd
- if "!n3:~-%split%,1!"=="0" (
-
- set /a split-=1
-
- goto pd
-
- ) else (
-
- call set a1=%%n3:~0,-%split%%%
-
- call set a2=%%n3:~-%split%%%
-
- goto :eof
-
- )
-
-
- :lh
-
- if not "!sc:~%num%,1!"=="" (set /a _split+=1) else (goto :eof)
-
- set /a num+=1
-
- goto lh
复制代码
看看是不是要这样的结果?
作者: 随风 时间: 2008-3-1 18:00
好像不对啊,我在地址栏直接输入12345也不对啊,???
不知道是什么问题,不过到是学到了怎么通过网址得到ip地址
ping /n 1 %input%^|find /i "ping statistics
作者: ieutk 时间: 2008-3-1 19:04
我也不知道是不是这样,不过输入“12345”,是中央人民政府门户网站首页
要想实现这个功能首先还的要安装一个插件
插件名字叫"中国十进制网络安全地址"
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |