← back to Dw Cowtan Recrawl
probe3.js
24 lines
#!/usr/bin/env node
const https = require('https');
function raw(method, url, body) {
return new Promise((resolve, reject) => {
const p = new URL(url);
const opts = { hostname: p.hostname, port: 443, path: p.pathname + p.search, method, timeout: 30000,
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/120 Safari/537.36', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest' } };
if (body) { opts.headers['Content-Type'] = 'application/x-www-form-urlencoded'; opts.headers['Content-Length'] = Buffer.byteLength(body); }
const req = https.request(opts, res => { let d = ''; res.on('data', c => d += c); res.on('end', () => resolve({ status: res.statusCode, loc: res.headers.location, ct: res.headers['content-type'], body: d })); });
req.on('error', reject); req.on('timeout', () => { req.destroy(); reject(new Error('timeout')); });
if (body) req.write(body); req.end();
});
}
function buildBody(pi, tv) { const p = ['Keywords=', 'NewOnly=false']; ['F', 'W', 'T'].forEach((t, i) => { p.push('Types%5B' + i + '%5D.Value=' + t); p.push('Types%5B' + i + '%5D.Selected=' + (t === tv ? 'true' : 'false')); }); p.push('PageIndex=' + pi); return p.join('&'); }
(async () => {
const r = await raw('POST', 'https://designs.cowtan.com/Search', buildBody(0, 'W'));
console.log('POST /Search ->', r.status, r.ct, 'loc=' + (r.loc || '-'), 'len=' + r.body.length);
console.log('--- first 600 chars ---\n' + r.body.slice(0, 600));
// try the apex / www host
for (const h of ['https://designs.cowtan.com/', 'https://www.cowtan.com/', 'https://www.cowtantout.com/']) {
try { const x = await raw('GET', h); console.log('\nGET', h, '->', x.status, (x.ct || '').split(';')[0], 'len=' + x.body.length, 'loc=' + (x.loc || '-')); } catch (e) { console.log('GET', h, 'ERR', e.message); }
}
})().catch(e => console.error('FATAL', e.message));