Board logo

标题: [数值计算] 批处理如何把web地址转为十进制地址? [打印本页]

作者: youxi01    时间: 2008-2-29 00:28     标题: 批处理如何把web地址转为十进制地址?

web地址如何转为十进制地址?

如本论坛网址:bbs.bathome.net,是否可以把它转化为一个大整数,到时只要输入那个大整数,也可以访问本论坛?
作者: ieutk    时间: 2008-3-1 17:35

  1. @echo off&setlocal enabledelayedexpansion
  2. title code by ieutk @ bbs.bathome.net
  3. mode con: cols=65 lines=12
  4. color 1b
  5. set "split=4"
  6. set "_split=0"
  7. set "num=0"
  8. :main
  9. cls&echo.&echo.
  10. set input=
  11. set /p input=  请输入WEB地址:
  12. if not defined input goto main
  13. for /f "tokens=4 delims=: " %%a in ('ping /n 1 %input%^|find /i "ping statistics"') do set "ip=%%a"
  14. set "ip=%ip:.= %"
  15. set /a n3=256*256*256,n2=256*256
  16. call :pd
  17. for /f "tokens=1-4 delims= " %%a in ("%ip%") do (
  18. set "ie=%%a"
  19. set /a sc=%%b*n2+%%c*256+%%d
  20.     )
  21. set /a fs1=a1*ie,fs2=a2*ie
  22. call set /a fsn=%%fs2:~0,-%split%%%+fs1
  23. call set fs=%fsn%%%fs2:~-%split%%%
  24. call :lh
  25. call set /a zh=%%fs:~-%_split%%%+sc
  26. if not "!zh:~%_split%,1!"=="" (
  27. call set /a _h=%%fs:~0,-%_split%%%+%%zh:~0,-%_split%%%
  28. call set hh=%%_h%%%%zh:~-%_split%%%
  29.     ) else (
  30. call set hh=%%fs:~0,-%_split%%%%zh%
  31.     )
  32. echo  %hh%
  33. echo.&pause&goto :eof
  34. :pd
  35. if "!n3:~-%split%,1!"=="0" (
  36. set /a split-=1
  37. goto pd
  38.     ) else (
  39. call set a1=%%n3:~0,-%split%%%
  40. call set a2=%%n3:~-%split%%%
  41. goto :eof
  42.     )
  43. :lh
  44. if not "!sc:~%num%,1!"=="" (set /a _split+=1) else (goto :eof)
  45. set /a num+=1
  46. 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