Geolocation by IP address in Alaska

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Geolocation by IP address in Alaska

#1 Post 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?

User avatar
Auge_Ohr
Posts: 1343
Joined: Wed Feb 24, 2010 3:44 pm

Re: Geolocation by IP address in Alaska

#2 Post 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++
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Geolocation by IP address in Alaska

#3 Post 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++

User avatar
Auge_Ohr
Posts: 1343
Joined: Wed Feb 24, 2010 3:44 pm

Re: Geolocation by IP address in Alaska

#4 Post 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 :)
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Geolocation by IP address in Alaska

#5 Post by Eugene Lutsenko »

"ip-api.com " - this is not a local program, but a website

User avatar
rdonnay
Site Admin
Posts: 4559
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Geolocation by IP address in Alaska

#6 Post by rdonnay »

I have a problem reading the site into a text variable without opening the browser.
You can do this with LoadFromURL().
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Geolocation by IP address in Alaska

#7 Post 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)
Attachments
Безымянный2.jpg
Безымянный2.jpg (965.43 KiB) Viewed 853 times
Безымянный.jpg
Безымянный.jpg (234.49 KiB) Viewed 853 times

User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Geolocation by IP address in Alaska

#8 Post 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!
Attachments
Безымянный3.jpg
Безымянный3.jpg (56.45 KiB) Viewed 844 times
Безымянный2.jpg
Безымянный2.jpg (61.16 KiB) Viewed 844 times
Безымянный1.jpg
Безымянный1.jpg (38.54 KiB) Viewed 844 times

User avatar
Eugene Lutsenko
Posts: 1592
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Geolocation by IP address in Alaska

#9 Post by Eugene Lutsenko »

I did everything. It turned out well. FUNCTION RecreateDB() here: http://lc.kubagro.ru/__AidosALL.txt
Thank you all very much!

Post Reply