Skip to content

Commit

Permalink
feat: add skip_static to options
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Mar 11, 2020
1 parent 68f16ca commit 7981e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function start() {
fields_preset: 'seo', // варианты: default, seo, headers, minimal
maxConcurrency: 2, // параллельно открываемые вкладки
maxDepth: 10 // глубина сканирования
// ,skip_static: false // не пропускать подгрузку браузером статики (картинки, css, js)
// ,followSitemapXml: true // чтобы найти больше страниц
// ,maxRequest: 10 // для тестов
// ,headless: false // на десктопе открывает браузер визуально
Expand Down
10 changes: 7 additions & 3 deletions src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const DEBUG = true; // выключить, если не нужны console.log
const docs = ['doc', 'docx', 'xls', 'xlsx', 'pdf', 'rar', 'zip']; // можно дополнять

// запреты браузеру на подгрузку статики, ускоряет
const SKIP_IMAGES = true;
const SKIP_CSS = true;
const SKIP_JS = true;
let SKIP_IMAGES = true;
let SKIP_CSS = true;
let SKIP_JS = true;

// поля описаны в API по ссылке выше
const fields_presets = {
Expand Down Expand Up @@ -58,6 +58,10 @@ module.exports = async (baseUrl, options = {}) => {
}
const fields = fields_presets[options.fields_preset];

if (options.skip_static !== undefined) {
SKIP_IMAGES = SKIP_CSS = SKIP_JS = options.skip_static;
}

const exporter = new CSVExporter({
file: FILE,
fields: fields
Expand Down

0 comments on commit 7981e9b

Please sign in to comment.