MCPcopy
hub / github.com/ineo6/hosts / findIp

Function findIp

src/hosts.ts:48–73  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

46}
47
48async function findIp(host: string) {
49 const url = resolveUrl(host);
50
51 const response = await fetch(url, {
52 headers: headers
53 });
54 const htmlText = await response.text();
55
56 const $ = cheerio.load(htmlText);
57
58 const ipList: string[] = [];
59
60 $('#dnsinfo>tr')
61 .each((i, element) => {
62 let td = $(element).children();
63
64 if ($(td[1]).text() === 'A') {
65 ipList.push($(element)
66 .children()
67 .last()
68 .text());
69 }
70 });
71
72 return ipList;
73}
74
75async function findIpWrapper(host: string) {
76 let retryCount = 3;

Callers 1

findIpWrapperFunction · 0.85

Calls 1

resolveUrlFunction · 0.85

Tested by

no test coverage detected