Adressdaten aus Google

  • Ich habe ein kleines Script zur Abfrage von Adressdaten geschrieben. Es geht dabei um festzustellen wie der Abstand von einer Adresse zu mehren anderen ist. Mir ist das Script einfach zu langsam, könnt ihre helfen es schneller zu machen?

    [autoit]


    #include <IE.au3>
    #include <Array.au3>
    #include <GUIConstants.au3>
    #include <String.au3>
    $fadd = "berliiner Allee 10"
    $fcity = "Hannover"
    $fstate = "Germany"
    local $tadd[10],$tcity[10],$tstate[10],$End[10]
    $tadd[1] = "Seestrasse 5"
    $tcity[1] = "Berlin"
    $tstate[1] = "Germany"
    $tadd[2] = "Berliner Allee 4"
    $tcity[2] = "Hannover"
    $tstate[2] = "Germany"
    for $t = 1 to 2
    $Start = ($fadd & ", " & $fcity & " " & $fstate)
    $End[$t] = ($tadd[$t] & ", " & $tcity[$t] & " " & $tstate[$t])
    $sUrl = "http://maps.google.com/maps?f=d&hl=de&saddr="&StringReplace($start&"&daddr="&$End[$t]," ","+")
    $oIE = _IECreate($sUrl,0,0)
    _IELoadWait($oIE)
    $oDiv = _IEGetObjById($oIE, "altroute_0")
    $Result = (_IEPropertyGet($oDiv, "innerhtml"))
    $data = _StringBetween($Result, '<DIV class="altroute-rcol altroute-info">','</DIV>')
    ConsoleWrite($data[0]&@CRLF)
    Next

    [/autoit]

    Einmal editiert, zuletzt von kunstlust (21. Juli 2011 um 12:46)

  • Ich wollte eigentlich noch ein Script schreiben, aber ich bin grad auf dem Sprung.
    Das wird dir aber bestimmt weiter helfen:

    http://maps.googleapis.com/maps/api/distancematrix/xml?origins=berliiner+Allee+10,+Hannover,+Germany&destinations=Seestrasse+5,+Berlin,+Germany&sensor=false
    Die Google Apis sind schon was tolles :).

    http://maps.googleapis.com/maps/api/dista…ix/xml?origins=berliiner+Allee+10,+Hannover,+Germany&destinations=Seestrasse+5,+Berlin,+Germany&sensor=false

    Einfach ersetzen und mit _InetGetSource abrufen.

    Hier noch 2 Links zum lesen:
    http://code.google.com/intl/de-DE/api…distancematrix/
    http://code.google.com/intl/de-DE/api…ion/directions/


    lg


    /Edit, hab an sowas gedacht:

    [autoit]

    #include <INet.au3>
    #Include <Array.au3>
    #Include <String.au3>

    [/autoit][autoit][/autoit][autoit]

    Local $address[10][4] = [["berliiner Allee 10", "Hannover", "Germany"], _
    ["Seestrasse 5", "Berlin", "Germany"], _
    ["Berliner Allee 4", "Hannover", "Germany"]]

    [/autoit][autoit][/autoit][autoit]

    For $i = 1 To 2
    getDistance($address[0][0] & ' ' & $address[0][1] & ' ' & $address[0][2], _
    $address[$i][0] & ' ' & $address[$i][1] & ' ' & $address[$i][2])
    Next

    [/autoit][autoit][/autoit][autoit]

    Func getDistance($start, $stop)
    $source = _INetGetSource("http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" & _URLEncode($start) & "&destinations=" & _URLEncode($stop) & "&sensor=false")
    $source = _StringBetween($source, "<text>", "</text>")
    if UBound($source) <> 2 Then
    MsgBox(0,"Error", "Ein Fehler ist aufgetreten. Falsche Angaben?")
    Else
    _ArrayDisplay($source)
    EndIf
    EndFunc ;==>getDistance

    [/autoit][autoit][/autoit][autoit]

    Func _URLEncode($sData)
    ; Prog@ndy
    Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "")
    Local $nChar
    $sData = ""
    For $i = 1 To $aData[0]
    $nChar = Asc($aData[$i])
    Switch $nChar
    Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126
    $sData &= $aData[$i]
    Case 32
    $sData &= "+"
    Case Else
    $sData &= "%" & Hex($nChar, 2)
    EndSwitch
    Next
    Return $sData
    EndFunc ;==>_URLEncode

    [/autoit]

    Kannst auch noch die Ausgabesprache mit irgendnem Parameter umstellen, einfach mal umsehen :).

    2 Mal editiert, zuletzt von anno2008 (20. Juli 2011 um 21:23)

  • Ich danke dir anno2008, die XML Anfrage, ist was mir fehlte und dein Script ist super, danke.