(AutoIt) DNS Query AAAA Records
Shows how to perform a DNS query to retrieve AAAA records.
Note: This example requires Chilkat v9.5.0.96 or later.
$oDns = ObjCreate("Chilkat.Dns")
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False
Local $bSuccess = $oDns.Query("AAAA","x.com",$oJson)
If ($bSuccess = False) Then
ConsoleWrite($oDns.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oJson.Emit() & @CRLF)
; Sample response.
; Parsing code below..
; {
; "answer": {
; "aaaa": [
; {
; "name": "x.com",
; "ttl": 229,
; "ipv6": "2606:4700:4400::ac40:96f2"
; },
; {
; "name": "x.com",
; "ttl": 229,
; "ipv6": "2606:4700:4400::6812:250e"
; }
; ]
; }
; }
; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
Local $sName
Local $iTtl
Local $sIpv6
Local $i = 0
Local $iCount_i = $oJson.SizeOfArray("answer.aaaa")
While $i < $iCount_i
$oJson.I = $i
$sName = $oJson.StringOf("answer.aaaa[i].name")
$iTtl = $oJson.IntOf("answer.aaaa[i].ttl")
$sIpv6 = $oJson.StringOf("answer.aaaa[i].ipv6")
$i = $i + 1
Wend
|