Page 1 of 1

Geolocation by IP address in Alaska

Posted: Mon Jun 20, 2022 9:46 pm
by Eugene Lutsenko
There is a geolocation service: https://ip-api.com/#71.39.117.6 . How to pull information in curly brackets into a text variable?

Re: Geolocation by IP address in Alaska

Posted: Mon Jun 20, 2022 11:47 pm
by Auge_Ohr
hi Eugene,

i have try ">> Logme.TXT" and " | CLIP " but both does not work when call from App ... :(

so i create a *.BAT and call that *.BAT

Code: Select all

   nHandle := FCREATE( cFile, FC_NORMAL )
   IF nHandle == - 1
      MsgInfo( "Error create File : " + cFile, STR( FERROR() ) )
      RETURN
   ELSE
      FWRITE( nHandle, cRun + cPara + cClip)
      FCLOSE( nHandle )
   ENDIF

   System.EmptyClipboard
   ShellExecute( 0, "open", cFile,,, SW_HIDE )

   DO WHILE EMPTY(System.Clipboard )
      hb_idleSleep( 0.1 )
   ENDDO
   cMemo := System.Clipboard
it is HMG Syntax but should be easy to translate to Xbase++

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 1:07 am
by Eugene Lutsenko
Hi, Jimmy! I have a problem reading the site into a text variable without opening the browser. The rest is not a problem for me
Auge_Ohr wrote: Mon Jun 20, 2022 11:47 pm hi Eugene,

i have try ">> Logme.TXT" and " | CLIP " but both does not work when call from App ... :(

so i create a *.BAT and call that *.BAT

Code: Select all

   nHandle := FCREATE( cFile, FC_NORMAL )
   IF nHandle == - 1
      MsgInfo( "Error create File : " + cFile, STR( FERROR() ) )
      RETURN
   ELSE
      FWRITE( nHandle, cRun + cPara + cClip)
      FCLOSE( nHandle )
   ENDIF

   System.EmptyClipboard
   ShellExecute( 0, "open", cFile,,, SW_HIDE )

   DO WHILE EMPTY(System.Clipboard )
      hb_idleSleep( 0.1 )
   ENDDO
   cMemo := System.Clipboard
it is HMG Syntax but should be easy to translate to Xbase++

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 1:25 am
by Auge_Ohr
Eugene Lutsenko wrote: Tue Jun 21, 2022 1:07 am Hi, Jimmy! I have a problem reading the site into a text variable without opening the browser. The rest is not a problem for me
this is exact what i do :!:

Code: Select all

PROCEDURE MAIN(cNewIP)
LOCAL cRun := "curl "
LOCAL cPara := "ip-api.com "
LOCAL cClip := " | CLIP "
LOCAL cFile := "GetIP.BAT"
LOCAL cMemo , nHandle
i do write "GetIP.BAT" from App and than call it and now " | CLIP" or ">> LogMe.TXT" can work :)

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 7:17 am
by Eugene Lutsenko
"ip-api.com " - this is not a local program, but a website

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 7:18 am
by rdonnay
I have a problem reading the site into a text variable without opening the browser.
You can do this with LoadFromURL().

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 7:57 am
by Eugene Lutsenko
rdonnay wrote: Tue Jun 21, 2022 7:18 am
I have a problem reading the site into a text variable without opening the browser.
You can do this with LoadFromURL().
When I launch in the browser address bar http://ip-api.com/#71.39.117.6 I get: It suits me fine. But I would like to get the html code drawing this page in the browser. When I try to do this, it turns out that.

Code: Select all

cResponse := LoadFromURL( 'http://ip-api.com/#71.39.117.6' )
MsgBox(cResponse)

Re: Geolocation by IP address in Alaska

Posted: Tue Jun 21, 2022 11:54 am
by Eugene Lutsenko

Code: Select all

     cResponse := LoadFromURL( 'http://ip-api.com/#71.39.117.6' )
     MsgBox(cResponse)

     cResponse := LoadFromURL( 'http://ip-api.com/json/71.39.117.6' )
     MsgBox('json'+', '+cResponse)

     cResponse := LoadFromURL( 'http://ip-api.com/xml/71.39.117.6' )
     MsgBox('xml'+', '+cResponse)

     cResponse := LoadFromURL( 'http://ip-api.com/csv/71.39.117.6' )
     MsgBox('csv'+', '+cResponse)

     cResponse := LoadFromURL( 'http://ip-api.com/line/71.39.117.6' )
     MsgBox('line'+', '+cResponse)

     cResponse := LoadFromURL( 'http://ip-api.com/php/71.39.117.6' )
     MsgBox('php'+', '+cResponse)
It seems like everything I wanted turned out!

Re: Geolocation by IP address in Alaska

Posted: Fri Jun 24, 2022 10:08 am
by Eugene Lutsenko
I did everything. It turned out well. FUNCTION RecreateDB() here: http://lc.kubagro.ru/__AidosALL.txt
Thank you all very much!