本帖最后由 pcl_test 于 2016-9-4 19:52 编辑
522235677 发表于 2013-4-9 14:40
照搬代码,试试。- @echo off
- more /e +10 %0 >"%temp%\down.vbs"
- wscript //b "%temp%\down.vbs" "http://1212.ip138.com/ic.asp" "%temp%\ip.txt"
- FOR /F "usebackq tokens=2 delims=[]" %%i in ("%temp%\ip.txt") do set ip=%%i
- if "%ip%"=="" (set "ip=ip138.com源码已变更。")
- for /f "usebackq tokens=2 delims=]" %%a in ("%temp%\ip.txt") do (for /f "delims=<" %%b in ("%%a") do set "ad=%%b")
- echo %ad% IP:%ip%
- pause&exit
-
-
-
- Call DownloadFile(WScript.Arguments.Item(0), WScript.Arguments.Item(1))
- Function DownloadFile(URL,SavePath)
- On Error Resume Next
- Dim fso, xPost
- Set fso= Wscript.Createobject("Scripting.FileSystemObject")
- Set xPost = createObject("Microsoft.XMLHTTP")
- xPost.Open "GET",URL,0 ''''下载文件的地址
- xPost.Send()
- Set sGet = CreateObject("ADODB.Stream")
- sGet.Mode = 3
- sGet.Type = 1
- sGet.Open()
- sGet.Write(xPost.responseBody)
- sGet.SaveToFile SavePath,2 ''''保存文件的路径和文件名
- if (fso.FileExists(SavePath)) Then '检测文件是否存在
- DownloadFile = True
- else
- DownloadFile = False
- end if
- set fso=Nothing
- End Function
复制代码 简体XP 32位执行结果如下:- 来自:广东省东莞市 电信 IP:183.22.169.214
- 请按任意键继续. . .
复制代码
|