Code: Select all
@echo off
setlocal enabledelayedexpansion
set /p "ip=IP: "
(
echo/Dim oXMLHTTP
echo/Dim oStream
echo/wscript.echo httpGet
echo/Function httpGet
echo/Set oXMLHTTP = CreateObject^("MSXML2.XMLHTTP.3.0"^)
echo/oXMLHTTP.Open "GET", "http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=!ip!", False
echo/oXMLHTTP.Send
echo/If oXMLHTTP.Status = 200 Then
echo/ Set oStream = CreateObject^("ADODB.Stream"^)
echo/ oStream.Open
echo/ oStream.Type = 1
echo/ oStream.Write oXMLHTTP.responseBody
echo/ oStream.Position = 0
echo/ oStream.Type = 2
echo/ oStream.CharSet = "ascii"
echo/ httpGet = oStream.ReadText
echo/ oStream.Close
echo/End If
echo/End Function
) > get.vbs
for /f "tokens=2,3" %%a in ('cscript //nologo get.vbs') do (
set "content=%%b"
set "content=!content:~0,-1!"
echo/%%a !content!>>teste.txt)
type teste.txt|find /v /i "templa">_teste.txt
del teste.txt&ren _teste.txt teste.txt
for /f "tokens=1,2" %%a in ('type teste.txt') do (
for /f "tokens=1,2 delims==" %%k in ('echo/%%a 2^>nul') do (
set "_info=%%k"
if "!_info!" == "name" (set "info=%%~l")
)
set "info=!info:~0,-2!"
for /f "tokens=2* delims==" %%k in ('echo/%%b') do (
if "!_info!" == "name" (set "info=!info! : %%~k")
)
echo/!info! 2>nul
)
pause > nul
del get.vbs
del teste.txt