Not parsing HTML with jsdom when using http module directly to save memory. Added loading ellipsis to release grid pages.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const log = require('why-is-node-running');
|
||||
// const log = require('why-is-node-running');
|
||||
const Inspector = require('inspector-api');
|
||||
const fs = require('fs').promises;
|
||||
const dayjs = require('dayjs');
|
||||
@@ -24,8 +24,10 @@ const getFileEntries = require('./utils/file-entries');
|
||||
const inspector = new Inspector();
|
||||
|
||||
function logActive() {
|
||||
console.log('log active!');
|
||||
|
||||
setTimeout(() => {
|
||||
log();
|
||||
// log();
|
||||
logActive();
|
||||
}, typeof argv.logActive === 'number' ? argv.logActive : 60000);
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ async function getSession(site, parameters) {
|
||||
session,
|
||||
interval: parameters?.interval,
|
||||
concurrency: parameters?.concurrency,
|
||||
parse: false,
|
||||
});
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
|
||||
@@ -23,6 +23,7 @@ Promise.config({
|
||||
const defaultOptions = {
|
||||
timeout: argv.requestTimeout,
|
||||
encodeJSON: true,
|
||||
parse: false,
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
|
||||
},
|
||||
@@ -114,14 +115,14 @@ async function finalizeResult(res, options) {
|
||||
|
||||
if (Buffer.isBuffer(res.body)) {
|
||||
const html = res.body.toString();
|
||||
const window = new JSDOM(html, { virtualConsole, ...options.extract }).window;
|
||||
const window = options?.parse ? new JSDOM(html, { virtualConsole, ...options.extract }).window : null;
|
||||
|
||||
return {
|
||||
...res,
|
||||
body: html,
|
||||
html,
|
||||
status: res.statusCode,
|
||||
document: window.document,
|
||||
document: window?.document || null,
|
||||
window,
|
||||
ok: res.statusCode >= 200 && res.statusCode <= 299,
|
||||
};
|
||||
|
||||
@@ -521,7 +521,11 @@ function extractAll(htmlValue, selector, options) {
|
||||
async function request(method = 'get', urlValue, body, selector, headers, options, queryAll = false) {
|
||||
const res = await (method === 'post'
|
||||
? http.post(urlValue, body, { ...options, headers })
|
||||
: http[method](urlValue, { ...options, headers }));
|
||||
: http[method](urlValue, {
|
||||
...options,
|
||||
headers,
|
||||
parse: true,
|
||||
}));
|
||||
|
||||
if (res.ok) {
|
||||
const item = queryAll
|
||||
|
||||
Reference in New Issue
Block a user