diff --git a/CHANGELOG.md b/CHANGELOG.md index 35213a2..5a23ae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ -## [1.3.4](https://github.com/devalexanderdaza/puppeteer-extends/compare/v1.3.3...v1.3.4) (2021-10-29) +# [1.4.0](https://github.com/devalexanderdaza/puppeteer-extends/compare/v1.3.4...v1.4.0) (2021-10-29) + + +### Features + +* **puppeter-arguments:** implemented puppeter arguments and path logs ([f33210b](https://github.com/devalexanderdaza/puppeteer-extends/commit/f33210bf67f1a4dedc9f49604ddd6418e5068c8c)) +## [1.3.4](https://github.com/devalexanderdaza/puppeteer-extends/compare/v1.3.3...v1.3.4) (2021-10-29) ### Bug Fixes -* **documentation:** updated readme and examples ([7d2fca9](https://github.com/devalexanderdaza/puppeteer-extends/commit/7d2fca94c421b217502ec282f41bc22d77f581a9)) +- **documentation:** updated readme and examples ([7d2fca9](https://github.com/devalexanderdaza/puppeteer-extends/commit/7d2fca94c421b217502ec282f41bc22d77f581a9)) ## [1.3.3](https://github.com/devalexanderdaza/puppeteer-extends/compare/v1.3.2...v1.3.3) (2021-10-29) diff --git a/README.md b/README.md index f1f17f7..0c78fb4 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,86 @@ # puppeteer-extends + [![License][]](https://opensource.org/licenses/Apache-2.0) [![Build Status]](https://github.com/devalexanderdaza/puppeteer-extends/actions/workflows/ci.yml) [![NPM Package]](https://npmjs.org/package/puppeteer-extends) [![semantic-release]](https://github.com/semantic-release/semantic-release) -[License]: https://img.shields.io/badge/License-Apache%202.0-blue.svg -[Build Status]: https://github.com/devalexanderdaza/puppeteer-extends/actions/workflows/ci.yml/badge.svg -[NPM Package]: https://img.shields.io/npm/v/puppeteer-extends.svg +[license]: https://img.shields.io/badge/License-Apache%202.0-blue.svg +[build status]: https://github.com/devalexanderdaza/puppeteer-extends/actions/workflows/ci.yml/badge.svg +[npm package]: https://img.shields.io/npm/v/puppeteer-extends.svg [semantic-release]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg > Easy manage and instance a puppeteer using a singleton pattern. Minimal configuration implemented for install and use. ## Install -``` shell +```shell npm install puppeteer-extends ``` ## Use -``` javascript +```javascript const { PuppeteerExtends, Logger } = require("puppeteer-extends"); const path = require("path"); const { Browser, Page } = require("puppeteer"); // Define your custom browser arguments const customArguments = [ - "--no-sandbox", - "--disable-web-security", - "--disable-setuid-sandbox", - "--aggressive-cache-discard", - "--disable-cache", - "--disable-infobars", - "--disable-application-cache", - "--window-position=0,0", - "--disable-offline-load-stale-cache", - "--disk-cache-size=0", - "--disable-background-networking", - "--disable-default-apps", - "--disable-extensions", - "--disable-sync", - "--disable-translate", - "--hide-scrollbars", - "--metrics-recording-only", - "--mute-audio", - "--no-first-run", - "--safebrowsing-disable-auto-update", - "--ignore-certificate-errors", - "--ignore-ssl-errors", - "--ignore-certificate-errors-spki-list", + "--no-sandbox", + "--disable-web-security", + "--disable-setuid-sandbox", + "--aggressive-cache-discard", + "--disable-cache", + "--disable-infobars", + "--disable-application-cache", + "--window-position=0,0", + "--disable-offline-load-stale-cache", + "--disk-cache-size=0", + "--disable-background-networking", + "--disable-default-apps", + "--disable-extensions", + "--disable-sync", + "--disable-translate", + "--hide-scrollbars", + "--metrics-recording-only", + "--mute-audio", + "--no-first-run", + "--safebrowsing-disable-auto-update", + "--ignore-certificate-errors", + "--ignore-ssl-errors", + "--ignore-certificate-errors-spki-list", ]; // Folder of puppeteer store data const puppeteerDataDirectory = path.join(__dirname, "./tmp/puppeteer-extends"); const main = async () => { - // Set custom parameters on init browser instance - const browser = await PuppeteerExtends.getBrowser({ - isHeadless: true, - isDebug: false, - customArguments: customArguments, - userDataDir: puppeteerDataDirectory, - }); - if (browser) { - const page = await browser.newPage(); - - // * An example of crawling a page with CloudFlare applied. - Logger.debug("🚧 Crawling in progress..."); - - const url = "https://github.com/devalexanderdaza"; - await PuppeteerExtends.goto(page, url); - await page.screenshot({ - path: path.join(__dirname, "./tmp/puppeteer-extends/example-js.png"), - }); - - Logger.debug("🚧 Crawling is complete."); - Logger.debug("🚧 Closing page..."); - PuppeteerExtends.closePage(page); - Logger.debug("🚧 Exit the Puppeteer..."); - PuppeteerExtends.closeBrowser(browser); - } + // Set custom parameters on init browser instance + const browser = await PuppeteerExtends.getBrowser({ + isHeadless: true, + isDebug: false, + customArguments: customArguments, + userDataDir: puppeteerDataDirectory, + }); + if (browser) { + const page = await browser.newPage(); + + // * An example of crawling a page with CloudFlare applied. + Logger.debug("🚧 Crawling in progress..."); + + const url = "https://github.com/devalexanderdaza"; + await PuppeteerExtends.goto(page, url); + await page.screenshot({ + path: path.join(__dirname, "./tmp/puppeteer-extends/example-js.png"), + }); + + Logger.debug("🚧 Crawling is complete."); + Logger.debug("🚧 Closing page..."); + PuppeteerExtends.closePage(page); + Logger.debug("🚧 Exit the Puppeteer..."); + PuppeteerExtends.closeBrowser(browser); + } }; main().then(); @@ -87,8 +88,8 @@ main().then(); ## TypeScript support -``` typescript -import { PuppeteerExtends, Logger } from 'puppeteer-extends'; +```typescript +import { PuppeteerExtends, Logger } from "puppeteer-extends"; import path from "path"; import { Browser, Page } from "puppeteer"; diff --git a/dist/index.d.ts b/dist/index.d.ts index e668b3b..595ae01 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,28 +1,14 @@ -import * as PuppeteerExtends from './main/puppeteer'; -import { Logger } from './main/logger'; +import * as PuppeteerExtends from "./main/puppeteer"; +import { Logger } from "./main/logger"; /** * Main instances of puppeteer-extends * * ```typescript * import { PuppeteerExtends, Logger } from 'puppeteer-extends'; + * ``` * - * const main = async () => { - * const browser = await PuppeteerExtends.getBrowser({ isHeadless: true }); - * if (browser) { - * const page = await browser.newPage(); - * // An example of crawling a page with CloudFlare applied. - * Logger.debug('🚧 Crawling in progress...'); - * const url = 'https://github.com/devalexanderdaza'; - * await PuppeteerExtends.goto(page, url); - * await page.screenshot({ path: 'devalexanderdaza-github-screenshot.png' }); - * - * Logger.debug('🚧 Crawling is complete.'); - * Logger.debug('🚧 Exit the Puppeteer...'); - * await browser.close(); - * } - * } - * - * main().then(r => {}); + * ```javascript + * const { PuppeteerExtends, Logger } = require("puppeteer-extends"); * ``` */ export { PuppeteerExtends, Logger }; diff --git a/dist/index.js.map b/dist/index.js.map index a4c045a..12d7175 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AA6B5C,4CAAgB;AA5BzB,wCAAuC;AA4BZ,uFA5BlB,eAAM,OA4BkB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAc5C,4CAAgB;AAbzB,wCAAuC;AAaZ,uFAblB,eAAM,OAakB"} \ No newline at end of file diff --git a/dist/main/logger.d.ts b/dist/main/logger.d.ts index b1805eb..7d9ae79 100644 --- a/dist/main/logger.d.ts +++ b/dist/main/logger.d.ts @@ -1,7 +1,7 @@ /** * @since 1.0.0 */ -import { FolderLogger } from 'folder-logger'; +import { FolderLogger } from "folder-logger"; /** * Export library components * diff --git a/dist/main/moment.d.ts b/dist/main/moment.d.ts index d1a1b16..fcbba08 100644 --- a/dist/main/moment.d.ts +++ b/dist/main/moment.d.ts @@ -1,3 +1,3 @@ -import moment from 'moment'; -import 'moment/locale/en'; +import moment from "moment"; +import "moment/locale/en"; export { moment }; diff --git a/dist/main/moment.js b/dist/main/moment.js index dc022fe..c71419a 100644 --- a/dist/main/moment.js +++ b/dist/main/moment.js @@ -7,5 +7,5 @@ exports.moment = void 0; var moment_1 = __importDefault(require("moment")); exports.moment = moment_1.default; require("moment/locale/en"); -moment_1.default.locale('en'); +moment_1.default.locale("en"); //# sourceMappingURL=moment.js.map \ No newline at end of file diff --git a/dist/main/puppeteer.d.ts b/dist/main/puppeteer.d.ts index c43857c..7afbe9a 100644 --- a/dist/main/puppeteer.d.ts +++ b/dist/main/puppeteer.d.ts @@ -18,7 +18,7 @@ interface IOptions { export declare const getBrowser: (options: IOptions) => Promise; /** * Go to that page using puppeteer. - * @ignore + * @since 1.0.0 */ export declare const goto: (page: puppeteer.Page, targetUrl: string, options?: { waitUntil: string[]; @@ -27,11 +27,13 @@ export declare const goto: (page: puppeteer.Page, targetUrl: string, options?: { }) => Promise; /** * Close page, not browser + * @since 1.4.0 * @param page */ export declare const closePage: (page: puppeteer.Page) => void; /** * Close browser and all pages + * @since 1.4.0 * @param browser */ export declare const closeBrowser: (browser: Browser) => void; diff --git a/dist/main/puppeteer.js b/dist/main/puppeteer.js index 8b2cf36..12e10bc 100644 --- a/dist/main/puppeteer.js +++ b/dist/main/puppeteer.js @@ -51,6 +51,7 @@ var path_1 = __importDefault(require("path")); var browserSingleton; /** * Custom browser arguments + * @since 1.4.0 */ var args = [ "--no-sandbox", @@ -129,8 +130,7 @@ var init = function (_a) { if (isDebug) logger_1.Logger.debug("\uD83D\uDEA7 Headless Chrome has been started."); // @ts-ignore - puppeteer_extra_1.default.setMaxListeners = function () { - }; + puppeteer_extra_1.default.setMaxListeners = function () { }; puppeteer_extra_1.default.use((0, puppeteer_extra_plugin_stealth_1.default)()); return [2 /*return*/, browser]; case 3: @@ -147,7 +147,7 @@ var init = function (_a) { }; /** * Go to that page using puppeteer. - * @ignore + * @since 1.0.0 */ var goto = function (page, targetUrl, options) { if (options === void 0) { options = { @@ -196,6 +196,7 @@ var goto = function (page, targetUrl, options) { exports.goto = goto; /** * Close page, not browser + * @since 1.4.0 * @param page */ var closePage = function (page) { @@ -204,6 +205,7 @@ var closePage = function (page) { exports.closePage = closePage; /** * Close browser and all pages + * @since 1.4.0 * @param browser */ var closeBrowser = function (browser) { diff --git a/dist/main/puppeteer.js.map b/dist/main/puppeteer.js.map index 96c5758..87c15ec 100644 --- a/dist/main/puppeteer.js.map +++ b/dist/main/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EAAE;gBACP,MAAM,CAAC,KAAK,CAAC,CAAC;aACjB;iBAAM;gBACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aACrC;QACL,CAAC,CAAC;IANF,CAME,CACL,CAAC;AACN,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B"} \ No newline at end of file +{"version":3,"file":"puppeteer.js","sourceRoot":"","sources":["../../src/main/puppeteer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oEAA6C;AAC7C,kGAA2D;AAC3D,8DAAwC;AACxC,mCAAkC;AAClC,8CAAwB;AAExB;;GAEG;AACH,IAAI,gBAA+C,CAAC;AAEpD;;;GAGG;AACH,IAAM,IAAI,GAAa;IACrB,cAAc;IACd,wBAAwB;IACxB,0BAA0B;IAC1B,4BAA4B;IAC5B,iBAAiB;IACjB,oBAAoB;IACpB,6BAA6B;IAC7B,uBAAuB;IACvB,oCAAoC;IACpC,qBAAqB;IACrB,iCAAiC;IACjC,wBAAwB;IACxB,sBAAsB;IACtB,gBAAgB;IAChB,qBAAqB;IACrB,mBAAmB;IACnB,0BAA0B;IAC1B,cAAc;IACd,gBAAgB;IAChB,oCAAoC;IACpC,6BAA6B;IAC7B,qBAAqB;IACrB,uCAAuC;CACxC,CAAC;AAYF;;;GAGG;AACI,IAAM,UAAU,GAAG,UACxB,OAAiB;;;;qBAEb,CAAC,gBAAgB,EAAjB,wBAAiB;gBACA,qBAAM,IAAI,CAAC,OAAO,CAAC,EAAA;;gBAAtC,gBAAgB,GAAG,SAAmB,CAAC;;oBAEzC,sBAAO,gBAAgB,EAAC;;;KACzB,CAAC;AAPW,QAAA,UAAU,cAOrB;AAEF;;;GAGG;AACH,IAAM,IAAI,GAAG,UAAO,EAKnB;QAJC,kBAAiB,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACjB,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA,EACf,uBAAsB,EA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kBAAkB,GAAG,UAAC,GAAG;IACpC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,aAAa;QACb,OAAA,sBAAY,CAAC,GAAG,CAAC,GAAG,EAAE,UAAC,KAAK,EAAE,QAAQ,EAAE,IAAI;YAC1C,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAC;aACf;iBAAM;gBACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aACnC;QACH,CAAC,CAAC;IANF,CAME,CACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B"} \ No newline at end of file diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index bd19eed..06988ea 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -9,12 +9,14 @@ --dark-hl-3: #CE9178; --light-hl-4: #0000FF; --dark-hl-4: #569CD6; - --light-hl-5: #795E26; - --dark-hl-5: #DCDCAA; - --light-hl-6: #0070C1; - --dark-hl-6: #4FC1FF; + --light-hl-5: #0070C1; + --dark-hl-5: #4FC1FF; + --light-hl-6: #795E26; + --dark-hl-6: #DCDCAA; --light-hl-7: #008000; --dark-hl-7: #6A9955; + --light-hl-8: #267F99; + --dark-hl-8: #4EC9B0; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -28,6 +30,7 @@ --hl-5: var(--light-hl-5); --hl-6: var(--light-hl-6); --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); } } @@ -40,6 +43,7 @@ --hl-5: var(--dark-hl-5); --hl-6: var(--dark-hl-6); --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); } } @@ -52,6 +56,7 @@ body.light { --hl-5: var(--light-hl-5); --hl-6: var(--light-hl-6); --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); } @@ -64,6 +69,7 @@ body.dark { --hl-5: var(--dark-hl-5); --hl-6: var(--dark-hl-6); --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); } @@ -75,4 +81,5 @@ body.dark { .hl-5 { color: var(--hl-5); } .hl-6 { color: var(--hl-6); } .hl-7 { color: var(--hl-7); } +.hl-8 { color: var(--hl-8); } pre, code { background: var(--code-background); } diff --git a/docs/assets/search.js b/docs/assets/search.js index 6fc6746..623657f 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = {"kinds":{"4":"Namespace","32":"Variable"},"rows":[{"id":0,"kind":4,"name":"PuppeteerExtends","url":"modules/PuppeteerExtends.html","classes":"tsd-kind-namespace"},{"id":1,"kind":32,"name":"Logger","url":"modules.html#Logger","classes":"tsd-kind-variable"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,6.931]],["parent/0",[]],["name/1",[1,6.931]],["parent/1",[]]],"invertedIndex":[["logger",{"_index":1,"name":{"1":{}},"parent":{}}],["puppeteerextends",{"_index":0,"name":{"0":{}},"parent":{}}]],"pipeline":[]}} \ No newline at end of file +window.searchData = {"kinds":{"4":"Namespace","32":"Variable","64":"Function"},"rows":[{"id":0,"kind":4,"name":"PuppeteerExtends","url":"modules/PuppeteerExtends.html","classes":"tsd-kind-namespace"},{"id":1,"kind":64,"name":"goto","url":"modules/PuppeteerExtends.html#goto","classes":"tsd-kind-function tsd-parent-kind-namespace","parent":"PuppeteerExtends"},{"id":2,"kind":64,"name":"closePage","url":"modules/PuppeteerExtends.html#closePage","classes":"tsd-kind-function tsd-parent-kind-namespace","parent":"PuppeteerExtends"},{"id":3,"kind":64,"name":"closeBrowser","url":"modules/PuppeteerExtends.html#closeBrowser","classes":"tsd-kind-function tsd-parent-kind-namespace","parent":"PuppeteerExtends"},{"id":4,"kind":32,"name":"Logger","url":"modules.html#Logger","classes":"tsd-kind-variable"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,2.877]],["parent/0",[]],["name/1",[1,13.863]],["parent/1",[0,0.226]],["name/2",[2,13.863]],["parent/2",[0,0.226]],["name/3",[3,13.863]],["parent/3",[0,0.226]],["name/4",[4,13.863]],["parent/4",[]]],"invertedIndex":[["closebrowser",{"_index":3,"name":{"3":{}},"parent":{}}],["closepage",{"_index":2,"name":{"2":{}},"parent":{}}],["goto",{"_index":1,"name":{"1":{}},"parent":{}}],["logger",{"_index":4,"name":{"4":{}},"parent":{}}],["puppeteerextends",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{}}}]],"pipeline":[]}} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 5c32614..70c7701 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,12 +19,12 @@

Install

Use

-
const { PuppeteerExtends, Logger } = require("puppeteer-extends");

const main = async () => {
const browser = await PuppeteerExtends.getBrowser({ isHeadless: true });
if (browser) {
const page = await browser.newPage();

// * An example of crawling a page with CloudFlare applied.
Logger.debug("🚧 Crawling in progress...");

const url = "https://github.com/devalexanderdaza";
await PuppeteerExtends.goto(page, url);
await page.screenshot({ path: "devalexanderdaza-github-screenshot.png" });

Logger.debug("🚧 Crawling is complete.");
Logger.debug("🚧 Exit the Puppeteer...");
await browser.close();
}
};

main().then((r) => {}); +
const { PuppeteerExtends, Logger } = require("puppeteer-extends");
const path = require("path");
const { Browser, Page } = require("puppeteer");

// Define your custom browser arguments
const customArguments = [
"--no-sandbox",
"--disable-web-security",
"--disable-setuid-sandbox",
"--aggressive-cache-discard",
"--disable-cache",
"--disable-infobars",
"--disable-application-cache",
"--window-position=0,0",
"--disable-offline-load-stale-cache",
"--disk-cache-size=0",
"--disable-background-networking",
"--disable-default-apps",
"--disable-extensions",
"--disable-sync",
"--disable-translate",
"--hide-scrollbars",
"--metrics-recording-only",
"--mute-audio",
"--no-first-run",
"--safebrowsing-disable-auto-update",
"--ignore-certificate-errors",
"--ignore-ssl-errors",
"--ignore-certificate-errors-spki-list",
];

// Folder of puppeteer store data
const puppeteerDataDirectory = path.join(__dirname, "./tmp/puppeteer-extends");

const main = async () => {
// Set custom parameters on init browser instance
const browser = await PuppeteerExtends.getBrowser({
isHeadless: true,
isDebug: false,
customArguments: customArguments,
userDataDir: puppeteerDataDirectory,
});
if (browser) {
const page = await browser.newPage();

// * An example of crawling a page with CloudFlare applied.
Logger.debug("🚧 Crawling in progress...");

const url = "https://github.com/devalexanderdaza";
await PuppeteerExtends.goto(page, url);
await page.screenshot({
path: path.join(__dirname, "./tmp/puppeteer-extends/example-js.png"),
});

Logger.debug("🚧 Crawling is complete.");
Logger.debug("🚧 Closing page...");
PuppeteerExtends.closePage(page);
Logger.debug("🚧 Exit the Puppeteer...");
PuppeteerExtends.closeBrowser(browser);
}
};

main().then();

TypeScript support

-
import { PuppeteerExtends, Logger } from "puppeteer-extends";

const main = async () => {
const browser = await PuppeteerExtends.getBrowser({ isHeadless: true });
if (browser) {
const page = await browser.newPage();

// * An example of crawling a page with CloudFlare applied.
Logger.debug("🚧 Crawling in progress...");

const url = "https://github.com/devalexanderdaza";
await PuppeteerExtends.goto(page, url);
await page.screenshot({ path: "devalexanderdaza-github-screenshot.png" });

Logger.debug("🚧 Crawling is complete.");
Logger.debug("🚧 Exit the Puppeteer...");
await browser.close();
}
};

main().then((r) => {}); +
import { PuppeteerExtends, Logger } from "puppeteer-extends";
import path from "path";
import { Browser, Page } from "puppeteer";

// Define your custom browser arguments
const customArguments: string[] = [
"--no-sandbox",
"--disable-web-security",
"--disable-setuid-sandbox",
"--aggressive-cache-discard",
"--disable-cache",
"--disable-infobars",
"--disable-application-cache",
"--window-position=0,0",
"--disable-offline-load-stale-cache",
"--disk-cache-size=0",
"--disable-background-networking",
"--disable-default-apps",
"--disable-extensions",
"--disable-sync",
"--disable-translate",
"--hide-scrollbars",
"--metrics-recording-only",
"--mute-audio",
"--no-first-run",
"--safebrowsing-disable-auto-update",
"--ignore-certificate-errors",
"--ignore-ssl-errors",
"--ignore-certificate-errors-spki-list",
];

// Folder of puppeteer store data
const puppeteerDataDirectory = path.join(__dirname, "./tmp/puppeteer-extends");

const main = async (): Promise<void> => {
// Set custom parameters on init browser instance
const browser: Browser | undefined = await PuppeteerExtends.getBrowser({
isHeadless: true,
isDebug: false,
customArguments: customArguments,
userDataDir: puppeteerDataDirectory,
});
if (browser) {
const page: Page = await browser.newPage();

// * An example of crawling a page with CloudFlare applied.
Logger.debug("🚧 Crawling in progress...");

const url: string = "https://github.com/devalexanderdaza";
await PuppeteerExtends.goto(page, url);
await page.screenshot({
path: path.join(__dirname, "./tmp/puppeteer-extends/example.png"),
});

Logger.debug("🚧 Crawling is complete.");
Logger.debug("🚧 Closing page...");
PuppeteerExtends.closePage(page);
Logger.debug("🚧 Exit the Puppeteer...");
PuppeteerExtends.closeBrowser(browser);
}
};

main().then();

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 5fe7abc..9540e4a 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,5 +1,7 @@ -puppeteer-extends
Options
All
  • Public
  • Public/Protected
  • All
Menu

puppeteer-extends

Index

Namespaces

Variables

Variables

Logger

Logger: FolderLogger = ...
+puppeteer-extends
Options
All
  • Public
  • Public/Protected
  • All
Menu

puppeteer-extends

Index

Namespaces

Variables

Variables

Logger

Logger: FolderLogger = ...

Main instances of puppeteer-extends

-
import { PuppeteerExtends, Logger } from 'puppeteer-extends';

const main = async () => {
const browser = await PuppeteerExtends.getBrowser({ isHeadless: true });
if (browser) {
const page = await browser.newPage();
// An example of crawling a page with CloudFlare applied.
Logger.debug('🚧 Crawling in progress...');
const url = 'https://github.com/devalexanderdaza';
await PuppeteerExtends.goto(page, url);
await page.screenshot({ path: 'devalexanderdaza-github-screenshot.png' });

Logger.debug('🚧 Crawling is complete.');
Logger.debug('🚧 Exit the Puppeteer...');
await browser.close();
}
}

main().then(r => {}); +
import { PuppeteerExtends, Logger } from 'puppeteer-extends';
+
+
const { PuppeteerExtends, Logger } = require("puppeteer-extends");
 

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/PuppeteerExtends.html b/docs/modules/PuppeteerExtends.html index bf59995..404e36e 100644 --- a/docs/modules/PuppeteerExtends.html +++ b/docs/modules/PuppeteerExtends.html @@ -1,5 +1,18 @@ PuppeteerExtends | puppeteer-extends
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace PuppeteerExtends

Main instances of puppeteer-extends

-
import { PuppeteerExtends, Logger } from 'puppeteer-extends';

const main = async () => {
const browser = await PuppeteerExtends.getBrowser({ isHeadless: true });
if (browser) {
const page = await browser.newPage();
// An example of crawling a page with CloudFlare applied.
Logger.debug('🚧 Crawling in progress...');
const url = 'https://github.com/devalexanderdaza';
await PuppeteerExtends.goto(page, url);
await page.screenshot({ path: 'devalexanderdaza-github-screenshot.png' });

Logger.debug('🚧 Crawling is complete.');
Logger.debug('🚧 Exit the Puppeteer...');
await browser.close();
}
}

main().then(r => {}); +
import { PuppeteerExtends, Logger } from 'puppeteer-extends';
 
-

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +
const { PuppeteerExtends, Logger } = require("puppeteer-extends");
+
+

Index

Functions

Const closeBrowser

  • closeBrowser(browser: Browser): void
  • +

    Close browser and all pages

    +
    since

    1.4.0

    +

    Parameters

    • browser: Browser
      +

    Returns void

Const closePage

  • closePage(page: Page): void
  • +

    Close page, not browser

    +
    since

    1.4.0

    +

    Parameters

    • page: Page
      +

    Returns void

Const goto

  • goto(page: Page, targetUrl: string, options?: { isDebug: boolean; timeout: number; waitUntil: string[] }): Promise<boolean>
  • +

    Go to that page using puppeteer.

    +
    since

    1.0.0

    +

    Parameters

    • page: Page
    • targetUrl: string
    • options: { isDebug: boolean; timeout: number; waitUntil: string[] } = ...
      • isDebug: boolean
      • timeout: number
      • waitUntil: string[]

    Returns Promise<boolean>

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 51eaac7..d35f365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "puppeteer-extends", - "version": "1.3.4", + "version": "1.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c1ff404..6756fb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "puppeteer-extends", - "version": "1.3.4", + "version": "1.4.0", "description": "Easy manage and instance a puppeteer using a singleton pattern. Minimal configuration implemented for install and use.", "homepage": "https://github.com/devalexanderdaza/puppeteer-extends", "bugs": {