PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 24 → new Geo Ip Latitude Longitude
new Geo Ip Latitude Longitude
Débuté par adrianoboller, 18 nov. 2014 13:40 - Aucune réponse
Membre enregistré
2 962 messages
Popularité : +89 (91 votes)
Posté le 18 novembre 2014 - 13:40
Procedure WS_GeoIpLatitudeLongitude(LOCAL IP, LOCAL DebugSn)

ok is boolean = False

//Exemplo: "http://www.geoiptool.com/pt/201.21.151.121"

//Nome do Host: c9159779.virtua.com.br
//IP Address: 201.21.151.121
//País: Brazil brazil
//Código do país: BR (BRA)
//Região: Parana
//Cidade: Curitiba
//Código postal:
//Código tel.: +55
//Longitude: -49.25
//Latitude: -25.4167

//<table width="297" height="300" border="0" cellpadding="4" cellspacing="0" class="tbl_style">
//<tr>
//<td align="right"><span class="arial">Nome do Host:</span></td>
//<td width="198" align="left" class="arial_bold">c9159779.virtua.com.br</td>
//</tr>
//<tr>
//<td align="right"><span class="arial">IP Address:</span></td>
//<td align="left" class="arial_bold">201.21.151.121</td>
//</tr>
//<tr>
//<td align="right"><span class="arial">País:</span></td>
//<td align="left" class="arial_bold"><a href="http://en.wikipedia.org/wiki/brazil" target="_blank"> Brazil</a> <img src='/flags/br.gif' alt="brazil" align="absmiddle" ></td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Código do país:</span></td>
//<td align="left" class="arial_bold">BR (BRA)</td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Região:</span></td>
//<td align="left" class="arial_bold"><a href="http://en.wikipedia.org/wiki/Parana" target="_blank">Parana</a></td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Cidade:</span></td>
//<td align="left" class="arial_bold">Curitiba</td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Código postal:</span></td>
//<td align="left" class="arial_bold"></td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Código tel.:</span></td>
//<td align="left" class="arial_bold"><a href="http://en.wikipedia.org/wiki/Area_code#Brazil">+55</a></td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Longitude:</span></td>
//<td align="left" class="arial_bold">-49.25</td>
//</tr>
//<tr>
//<td align="right"><span class="arial">Latitude:</span></td>
//<td align="left" class="arial_bold">-25.4167</td>
//</tr>
//</table>

//IP = "201.21.151.121"

Url is string = "http://www.geoiptool.com/pt/"+ IP

Inicio, Fim is int = 0

sXml, Latitude, Longitude, Busca, sBuscaTD is string = ""

HTTPTimeOut(GloHTTPTimeOut)

ok = HTTPRequest(Url)

IF ok = True THEN

sXml = HTTPGetResult(httpResult)

sXml = Replace(sXml,"Matriz,","")
sXml = Replace(sXml,"Matriz","")

IF Length(sXml) > 0 THEN

Busca = "Longitude:"

Inicio = PositionOccurrence(sXml,Busca,firstRank)

Busca = "Latitude:"

Fim = PositionOccurrence(sXml,Busca,firstRank) + 100

sXml = Middle(sXml,Inicio, Fim-Inicio)

sXml = Replace(sXml, " ", "")

sXml = Replace(sXml, "<10>", "")

sXml = Replace(sXml, "<br>", "")

sXml = Replace(sXml, Charact(13), "")

sXml = Replace(sXml, Charact(10), "")

sXml = Replace(sXml, Charact(34), "")

sXml = Replace(sXml, Charact(13)+Charact(10), "")

sXml = Replace(sXml, "</span></td><tdalign=leftclass=arial_bold>", "")

sXml = Replace(sXml, "</td></tr><tr><tdalign=right><spanclass=arial>", "; ")

sXml = Replace(sXml, "</td>", "")

Inicio = PositionOccurrence(sXml,"Latitude:",firstRank,IgnoreCase)

Longitude = Middle(sXml,11,Inicio-13)

Latitude = Middle(sXml,Inicio+9,Length(sXml))

GloVoceLatitude = Latitude

GloVoceLongitude = Longitude

sXml = Latitude +"; "+ Longitude

IF DebugSn = "S"
fSaveText("c:\latlong.txt",sXml)
END

END

END

RESULT(sXml)