IP Publica desde vfp ya extraida

540 views
Skip to first unread message

Douglas Sánchez

unread,
Aug 15, 2012, 1:28:45 PM8/15/12
to publice...@googlegroups.com
Hola que tal he probado las rutinas que me han dando para extraer la ip publica de alguna pagina web en mi caso lo hago desde la pagina.

http://www.cual-es-mi-ip.net/

probe con las rutinas de portal fox e igual me trae el ip pero el codigo html completo tambien.

el problema es que me trae todo un archivo de html, se puede desde un txt extraer solo la ip publica ejemplo de este archivo html

parte del html


        <h1>mi ip</h1>
        <div class="central-contents"><!-- div:central-contents -->
            <p class="first"><span style="font-size: 32px">190.212.16.851</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:12px;"><a href="http://www.testdevelocidadmovil.es" target="_blank" style="color:#FF0000;">prueba el nuevo test de velocidad</a></span></p>
            <p><a style="color:#1E5B7E;font-size:14px;" href="http://www.adslzone.net/comparativa.html" target="_blank">Visita nuestra Comparativa ADSL y cable con todas las ofertas actuales</a></p>
        </div>
       
        <h1>mis datos</h1>


Desde ya muchas gracias.

--
Ing. Douglas Sánchez
    

Alejandro P

unread,
Aug 15, 2012, 1:34:56 PM8/15/12
to publice...@googlegroups.com
Hola a mi me dieron una rutina similar

tienes que cargar un form con un componente inet.

luego puse un boton en mi form que hace esto

InfoIP = thisform.inet1.openURL("http://dimemiip.com/")

varvalor=AT('class="ip"',InfoIP) 
thisform.text1.Value=SUBSTR(InfoIP,varvalor+11,15)
thisform.text1.Value=STRTRAN(thisform.text1.Value,"</h2>","")
thisform.Refresh()

Imágenes integradas 1



--
Ing. Douglas Sánchez
    

--
 
 
 

image.png

Andrés Oscar Gimbatti

unread,
Aug 15, 2012, 2:24:47 PM8/15/12
to publice...@googlegroups.com
Para que usas la IP Pública ?

Saludos
 

Oscar Díaz

unread,
Aug 15, 2012, 3:23:47 PM8/15/12
to publice...@googlegroups.com
Estimado Douglas:

Para obtener la ip publica sola, yo lo hago así:

ip = IpInternet()

FUNCTION IpInternet()
  DECLARE LONG URLDownloadToFile IN URLMON.DLL ;
    LONG, STRING, STRING, LONG, LONG
  ERASE "IP.txt"
  IF 0 = URLDownloadToFile(0, "http://www.whatismyip.org", "IP.txt", 0, 0)
    RETURN FILETOSTR("IP.txt")
  ELSE
    RETURN ""
  ENDIF
ENDPROC

Al darle modi comm a ip,txt aparece sólo la ip.

Espero le sirva.

Saludos desde Bogo

2012/8/15 Andrés Oscar Gimbatti <aogim...@gmail.com>
Para que usas la IP Pública ?

Saludos
 

--
 
 
 

Neyger Pérez Mayo

unread,
Aug 15, 2012, 3:24:44 PM8/15/12
to publice...@googlegroups.com
Si te es de utilidad:
 
LOCAL lcRet AS STRING
lcRet = ""
LOCAL loHT
TRY
 loHT = CREATEOBJECT("MSXML2.XMLHTTP")
CATCH TO oErr
ENDTRY
IF TYPE("loHT") == "O" THEN
 TRY
  lcXML = '<?xml version="1.0" encoding="utf-8"?>'
  lcXML = lcXML + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
  lcXML = lcXML + ' <soap:Body><Address xmlns="http://tempuri.org/" /></soap:Body>'
  lcXML = lcXML + '</soap:Envelope>'
  loHT.OPEN("POST","http://www.gncys.com/ws/remoteip.asmx",.F.)
  loHT.setRequestHeader("Content-Type", "text/xml")
  loHT.setRequestHeader("SOAPAction", "http://tempuri.org/Address")
  loHT.SEND(lcXML)
  LOCAL lcRet as String
  lcRet = loHT.ResponseText
  
  lcToken = ALLTRIM(loHT.ResponseText)
  LOCAL lnPos AS INTEGER
  lnPos = AT_C("</AddressResult>", lcRet )
  lcRet = LEFT(lcRet , lnPos-1)
  lnPos = AT_C("<AddressResult>", lcRet )
  lcRet = RIGHT(lcRet , LEN(lcRet ) - lnPos - 14)
  
 CATCH TO oErr
 ENDTRY
ENDIF
Messagebox(lcRet)
 
* RETURN lcRet
Te doy el link para que lo descargues:
remoteip.zip

Neyger Pérez Mayo

unread,
Aug 15, 2012, 3:39:48 PM8/15/12
to publice...@googlegroups.com
o si gusta probar de esta otra forma:
 
LOCAL loRemoteIP AS "XML Web Service"
* LOCAL loRemoteIP AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loRemoteIP = http://www.gncys.com/ws/remoteip.asmx?wsdl , RemoteIP , RemoteIPSoap
LOCAL loException, lcErrorMsg, loWSHandler
TRY
           loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
           loRemoteIP = loWSHandler.SetupClient("http://www.gncys.com/ws/remoteip.asmx?wsdl", "RemoteIP", "RemoteIPSoap")
CATCH TO loException
            lcErrorMsg="Error: "+TRANSFORM(loException.Errorno)+" - "+loException.Message
            DO CASE
            CASE VARTYPE(loRemoteIP)#"O"
                  * Handle SOAP error connecting to web service
            CASE !EMPTY(loRemoteIP.FaultCode)
                  * Handle SOAP error calling method
                   lcErrorMsg=lcErrorMsg+CHR(13)+loRemoteIP.Detail
             OTHERWISE
                   * Handle other error
             ENDCASE
             * Use for debugging purposes
             MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY
 
MESSAGEBOX(loRemoteIP.Address)
*RETURN loRemoteIP.Address
 
 
Te doy el link para que lo descargues:
 
 
 
RemoteIP2.zip
Reply all
Reply to author
Forward
0 new messages