Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save libook/722e3e87da4dde0f162ba19dc80ffb86 to your computer and use it in GitHub Desktop.
Save libook/722e3e87da4dde0f162ba19dc80ffb86 to your computer and use it in GitHub Desktop.
Get all dns records of a domain from DNSPod.
/*
<tbody>
<tr class="">
<td class="">
<div><label class="tea-form-check tea-form-check--table-select" name="523324"><input readonly=""
type="checkbox" class="tea-checkbox"><span class="tea-form-check__label">&nbsp;</span></label>
</div>
</td>
<td class="">
<div>
<div class="tea-domain dns-reacord-edit">
<div class="tea-domain__status"><i class="tea-icon tea-icon-status"></i></div>
<div class="tea-domain__text">*</div>
</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">A</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">默认</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">
127.0.0.1</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">-</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">-</div>
</div>
</td>
<td class="">
<div>
<div class="dns-reacord-edit">600</div>
</div>
</td>
<td class="">
<div>
<div>2019-07-07 11:00:57</div>
</div>
</td>
<td class="">
<div>
<div>
<div class="tea-flex--space-around"><a href="#"><i class="tea-icon tea-icon-stop"></i></a><a
href="https://monitor.dnspod.cn/wizard#/addmonitor/523324/*" target="_blank"><i
class="tea-icon tea-icon-monitor"></i></a><a href="#"><i
class="tea-icon tea-icon-remarks"></i></a><a href="#"><i
class="tea-icon tea-icon-delete"></i></a></div>
</div>
</div>
</td>
</tr>
</tbody>
*/
Array.from(document.querySelectorAll('tbody>tr')).map(row => {
const [record, type, line, value, weight, mxSeq, ttl, updatedAt] = row.innerText.trim().split('\n\t\n');
return { record, type, line, value, weight, mxSeq, ttl, updatedAt };
}).filter(dnsInfo => ['A', 'CNAME'].includes(dnsInfo.type));
/*
[
{
"record": "*",
"type": "A",
"line": "默认",
"value": "127.0.0.1",
"weight": "-",
"mxSeq": "-",
"ttl": "600",
"updatedAt": "2019-07-07 11:00:57"
}
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment