-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_iframe_requests.js
More file actions
29 lines (27 loc) · 1003 Bytes
/
Copy pathcheck_iframe_requests.js
File metadata and controls
29 lines (27 loc) · 1003 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
const fs = require('fs');
const path = require('path');
const fetch = globalThis.fetch || require('node-fetch');
const pages = ['pages/api02.html','pages/api03.html','pages/api04.html','pages/api05.html'];
(async ()=>{
for (const p of pages) {
try{
const content = fs.readFileSync(path.join(__dirname,p),'utf8');
const match = content.match(/url:\s*"([^"]+)"/);
const url = match ? match[1] : null;
console.log('---',p,'---');
if(!url){ console.log('No AJAX url found'); continue }
console.log('AJAX URL:',url);
try{
const r = await fetch(url,{method:'GET'});
console.log('FETCH STATUS', r.status, r.headers.get('content-type'));
const txt = await r.text();
console.log('BODY_LEN', txt.length);
console.log('BODY_PREVIEW', txt.slice(0,200).replace(/\n/g,' '));
}catch(e){
console.log('FETCH ERROR', e.message);
}
}catch(e){
console.log('READ FILE ERROR', e.message);
}
}
})();