init
This commit is contained in:
21
parser/scripts/check-session.js
Normal file
21
parser/scripts/check-session.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const config = require('../src/config');
|
||||
const { launchBrowser, createContext } = require('../src/session');
|
||||
const { fetchTargetHtmlWithSession } = require('../src/fetcher');
|
||||
|
||||
(async () => {
|
||||
const browser = await launchBrowser({ headless: config.headless });
|
||||
const context = await createContext({ browser, sessionFile: config.sessionFile });
|
||||
|
||||
const result = await fetchTargetHtmlWithSession({ context, config, targetUrl: config.targetUrl });
|
||||
console.log('HTTP status:', result.status);
|
||||
console.log('Current URL:', result.finalUrl);
|
||||
console.log('Title:', result.title);
|
||||
console.log('Auth required:', result.authRequired);
|
||||
console.log('\nHTML preview:\n');
|
||||
console.log(result.html.slice(0, 3000));
|
||||
|
||||
await browser.close();
|
||||
})().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user