Created
January 26, 2023 20:32
-
-
Save ogeday26/c052dbb87def36d0cf31e0d53e342c7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var script = document.createElement('script'); | |
script.onload = async function() { | |
var baseUrl = "https://www.nirsoft.net/countryip/"; | |
var parser = new DOMParser(); | |
var { | |
data: baseDom | |
} = await axios.get(baseUrl); | |
var parsedBaseDom = parser.parseFromString(baseDom, 'text/html'); | |
console.table((await Promise.all(Array.from(parsedBaseDom.querySelectorAll("body > table > tbody > tr:nth-child(2) > td:nth-child(3) > table > tbody > tr:nth-child(2) > td:nth-child(2) > p:nth-child(7) > table > tbody > tr > td > a")).map(item => ({ | |
href: item.href, | |
title: item.textContent | |
})).map(async item => { | |
var { | |
data | |
} = await axios.get(`${baseUrl}${item.href.split("/")[4]}`); | |
return { | |
title: item.title, | |
data | |
} | |
}))).map(item => { | |
var parsedDom = parser.parseFromString(item.data, 'text/html'); | |
var count = Array.from(parsedDom.querySelectorAll("body > table > tbody > tr:nth-child(2) > td:nth-child(3) > table > tbody > tr:nth-child(2) > td:nth-child(2) > p:nth-child(7) > table > tbody > tr > td:nth-child(3)")).map((item) => +item.textContent).reduce((a, b) => a + b, 0) | |
return { | |
title: item.title, | |
count | |
} | |
})) | |
}; | |
script.src = "https://cdnjs.cloudflare.com/ajax/libs/axios/1.2.5/axios.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1-> Open chrome new tab
2-> press f12
3-> paste code console
4-> press enter