Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- var list = []
- var errors = []
- async function run_page(page) {
- console.log("==PAGE " + page + "==")
- let req = await fetch("https://avenoel.org/mes-messages/" + page)
- if (req.status != 200) {
- console.log("Page " + page + "couldn't be fetched")
- errors.push(page)
- }
- let HTMLContent = await req.text()
- if (!HTMLContent.match(/message-permalink/)) {
- return false
- }
- let regex = /href="(https:\/\/image\.noelshack\.com\/fichiers\/.*?)"/g
- let matches = HTMLContent.matchAll(regex)
- let count = 0
- for (match of matches) {
- if (!list.includes(match[1]))
- list.push(match[1])
- count++
- }
- console.log(count + " noelshack URLs found on this page")
- return true;
- }
- async function run() {
- var page = 1
- while (await run_page(page)) {
- await sleep(15)
- page++
- }
- let res = ""
- for (url of list) {
- res += url + "<br />"
- }
- if (errors.length > 0)
- res += "<br />Those pages couldn't be fetch :<br />"
- for (page of errors) {
- res += ""
- }
- document.getElementsByTagName("html")[0].innerHTML = res
- }
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement