-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
35 lines (24 loc) · 844 Bytes
/
Copy pathtest.js
File metadata and controls
35 lines (24 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const puppeteer = require('puppeteer')
async function scanSite(url) {
console.log(" Launching browser...")
const browser = await puppeteer.launch({ headless: true})
const page = await browser.newPage()
console.log("going to:", url)
await page.goto(url, { waitUntil: 'networkidle2'})
// Get ALL lnks on the page
const links = await page.$$eval('a', els => els.map(el => el.href).filter(href => href.startsWith('http'))
)
console.log('Found links:', links)
for (const link of links) {
try {
const res = await fetch(link)
const status = res.status
const emoji = status === 200 ? 'yoo' : 'no'
console.log(`${emoji} ${status} ${link}`)
} catch(e) {
console.log(` noo Error - ${link}`)
}
}
await browser.close()
}
scanSite('https://sync-sooty.vercel.app/')