Fitgo Posted April 15, 2014 Posted April 15, 2014 I take this value, in lng: 16.2478996 This is the string: "bounds" : { "northeast" : { "lat" : 39.3137195, "lng" : 16.2478996 }, "southwest" : { "lat" : 39.3137169, "lng" : 16.2478815 } }, "location" : { "lat" : 39.3137169, "lng" : 16.2478996 }, "location_type" : "RANGE_INTERPOLATED", "viewport" : { "northeast" : { "lat" : 39.3150671802915, "lng" : 16.2492395302915 }, "southwest" : { "lat" : 39.3123692197085, "lng" : 16.24654156970849 } } The value is in here (in lng): "location" : { "lat" : 39.3137169, "lng" : 16.2478996 Let's say "lat" and "lon" can take on any value, just that it is a number with a dot and then another number. Example: 1.31 21.5790 33.12 and more...
somdcomputerguy Posted April 15, 2014 Posted April 15, 2014 So what is your question? That may help somebody answer it. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Fitgo Posted April 15, 2014 Author Posted April 15, 2014 (edited) I do not know how to take this value: 16.2478996 Is contained in "lng" in "location". Consists of numbers, a point and then other numbers. Thanks. Edited April 15, 2014 by Fitgo
FireFox Posted April 15, 2014 Posted April 15, 2014 Hi, #include <Array.au3> $s = FileRead("t.txt") $a = StringRegExp($s, '(?s)"location"(?:.*?)(\d+.\d+),', 3) _ArrayDisplay($a) Br, FireFox.
jdelaney Posted April 15, 2014 Posted April 15, 2014 This might help: IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
mikell Posted April 15, 2014 Posted April 15, 2014 Firefox, You've got a typo so you get the lat $a = StringRegExp($s, '(?s)"location".*?lng.*?([\d.]+)', 3)
FireFox Posted April 15, 2014 Posted April 15, 2014 (edited) oh yes, I was going to post the regex to get the lat and the lng until I saw he wanted only the lng. And thanks for your correction, much better Edited April 15, 2014 by FireFox
Fitgo Posted April 15, 2014 Author Posted April 15, 2014 #include <Array.au3> _Restituisci_latitudine("Via Lazio, 36, Cosenza") Func _Restituisci_latitudine($Indirizzo) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://maps.google.com/maps/api/geocode/json?address=" & $Indirizzo & "&sensor=false") $oHTTP.Send() $Codice_pagina = $oHTTP.Responsetext ; ConsoleWrite($Codice_pagina) $Stringa = StringRegExp($Codice_pagina, '(?s)"location"(?:.*?)(\d+.\d+),', 3) For $i = 0 To UBound($Stringa) - 1 Return $Stringa[$i] Next EndFunc Thank you very much, but I tried that and it does not work. jdelaney, it seems excessive use external UDF.
Fitgo Posted April 15, 2014 Author Posted April 15, 2014 Thanks but even whit (?s)"location".*?lng.*?([\d.]+) it doesn't work. #include <Array.au3> _Restituisci_latitudine("Via Lazio, 36, Cosenza") Func _Restituisci_latitudine($Indirizzo) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://maps.google.com/maps/api/geocode/json?address=" & $Indirizzo & "&sensor=false") $oHTTP.Send() $Codice_pagina = $oHTTP.Responsetext ; ConsoleWrite($Codice_pagina) $Stringa = StringRegExp($Codice_pagina, '(?s)"location".*?lng.*?([\d.]+)', 3) For $i = 0 To UBound($Stringa) - 1 Return $Stringa[$i] Next EndFunc I just need a value so do not know whether it is right to use For... :3
FireFox Posted April 15, 2014 Posted April 15, 2014 (edited) It does work, and btw you can only make one return. $s = _Restituisci_latitudine("Via Lazio, 36, Cosenza") ConsoleWrite("lng : " & $s) Func _Restituisci_latitudine($Indirizzo) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://maps.google.com/maps/api/geocode/json?address=" & $Indirizzo & "&sensor=false") $oHTTP.Send() $Codice_pagina = $oHTTP.Responsetext ConsoleWrite($Codice_pagina) $Stringa = StringRegExp($Codice_pagina, '(?s)"location"(?:.*?)(\d+.\d+),', 3) Return $Stringa[0] EndFunc Edited April 15, 2014 by FireFox
mikell Posted April 15, 2014 Posted April 15, 2014 (edited) Confirmation #include <Array.au3> $s = _Restituisci_latitudine("Via Lazio, 36, Cosenza") _ArrayDisplay($s) Func _Restituisci_latitudine($Indirizzo) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://maps.google.com/maps/api/geocode/json?address=" & $Indirizzo & "&sensor=false") $oHTTP.Send() $Codice_pagina = $oHTTP.Responsetext Return StringRegExp($Codice_pagina, '(?s)location".*?lat.*?([\d.]+).*?lng.*?([\d.]+)', 3) EndFunc You can make one return only but this can be an array Edited April 15, 2014 by mikell
Fitgo Posted April 21, 2014 Author Posted April 21, 2014 "lat" : 36.1805194, "lng" : -86.72654829999999 Before the number there could also be a hyphen. How do I resolve with: (?s)location".*?lat.*?([\d.]+).*?lng.*?([\d.]+) ? Thanks.
jdelaney Posted April 21, 2014 Posted April 21, 2014 (?s)location".*?lat.*?([-d.]+).*?lng.*?([-d.]+) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jchd Posted April 21, 2014 Posted April 21, 2014 In this context it's unlikely that Google would have fun with you by returning 5-6.7-523...47-5 To remove the possibility of wrong input, use this instead: (?s)location".*?lat.*?(-?d+(?:.d+)?).*?lng.*?(-?d+(?:.d+)?) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now