antibotbrowser 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +73 -0
  2. package/index.js +41 -0
  3. package/package.json +16 -0
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Usage
2
+ ## 1 - First let's start by installing the module
3
+ ```
4
+ npm install antibotbrowser
5
+
6
+ ```
7
+
8
+ ## 2 - Let's include our module in our project
9
+ ```js
10
+ const antibotbrowser = require("antibotbrowser");
11
+ ```
12
+
13
+ ## 3 - And let's run our browser
14
+ ```js
15
+ antibotbrowser = antibotbrowser.startbrowser();
16
+ ```
17
+
18
+ ## Arguments
19
+ ```js
20
+ antibotbrowser.startbrowser(port, url);
21
+ // port: The debugging port is the debugging port of the chromium browser. There can be 1 browser on the same port number, so you can add it as an argument. By default, if you enter nothing, the port is 9222.
22
+
23
+ // url: The first page address on browser startup. If you leave it blank, it defaults to google.com.
24
+
25
+ // Examples
26
+ antibotbrowser.startbrowser(9223, "https://github.com");
27
+ antibotbrowser.startbrowser(9222, "https://google.com");
28
+ // note do not start 2 scanners on the same port!!!
29
+ ```
30
+
31
+ ## Example uses
32
+ 1-
33
+ ```js
34
+ const antibotbrowser = require("antibotbrowser");
35
+ const puppeteer = require('puppeteer');
36
+ (async () => {
37
+
38
+ const antibrowser = await antibotbrowser.startbrowser(); // We start the browser with default settings. Port: 9222 Url: google.com
39
+
40
+ const browser = await puppeteer.connect({browserWSEndpoint: antibotbrowser.websokcet}); // We connect the launched browser to puppeteer. With the variable we created above, it gives the web socket url to puppetter with antibotbrowser.websocket .
41
+
42
+ // Normal use from now on
43
+ const page = await browser.newPage();
44
+
45
+ await page.setViewport({width:0, height:0});
46
+
47
+ page.goto("https://google.com")
48
+
49
+ })();
50
+ ```
51
+ 2-
52
+ ```js
53
+ const antibotbrowser = require("antibotbrowser");
54
+ const puppeteer = require('puppeteer');
55
+ (async () => {
56
+
57
+ const antibrowser = await antibotbrowser.startbrowser(9222, "https://google.com"); // We start the browser | Port: 9222 Url: google.com
58
+ const antibrowser2 = await antibotbrowser.startbrowser(9223, "https://github.com"); // 2. We create a browser | Port: 9223 Url: google.com
59
+
60
+ const browser = await puppeteer.connect({browserWSEndpoint: antibotbrowser.websokcet}); // We connect the launched browser to puppeteer. With the variable we created above, it gives the web socket url to puppetter with antibotbrowser.websocket .
61
+
62
+ const browser2 = await puppeteer.connect({browserWSEndpoint: antibotbrowser2.websokcet}); // 2. We have connected a browser in this way
63
+
64
+ const page2 = await browser2.newPage(); // 2. we opened a new tab in the browser
65
+ // Normal use from now on
66
+ const page = await browser.newPage();
67
+
68
+ await page.setViewport({width:0, height:0});
69
+
70
+ page.goto("https://google.com")
71
+
72
+ })();
73
+ ```
package/index.js ADDED
@@ -0,0 +1,41 @@
1
+ const chromium = require('chromium');
2
+ const {execFile} = require('child_process');
3
+ var request = require('sync-request');
4
+
5
+ // github.com/reloxe
6
+ // nokersoft.com
7
+
8
+ const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
9
+
10
+ async function startbrowser(port, url) {
11
+ try {
12
+
13
+ if (typeof port !== "string") {
14
+ url = "https://google.com";
15
+ }
16
+
17
+ if (typeof port !== "number") {
18
+ port = 9222;
19
+ }
20
+
21
+ execFile(chromium.path, [`--remote-debugging-port=${port}`, url], err => {
22
+ console.log(err);
23
+ });
24
+ await delay(4000);
25
+ var res = await request('GET', `http://127.0.0.1:${port}/json/version`);
26
+ veri = await JSON.parse(res.getBody())
27
+ useragent = await veri["User-Agent"];
28
+ websokcet = await veri["webSocketDebuggerUrl"];
29
+
30
+ return { useragent, websokcet };
31
+
32
+ } catch (error) {
33
+ return error;
34
+ }
35
+
36
+
37
+ }
38
+
39
+ module.exports = {
40
+ startbrowser
41
+ };
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "antibotbrowser",
3
+ "version": "1.0.1",
4
+ "readme": "README.md",
5
+ "description": "Opening Chromium opens a real browser without bot validations in automated systems like Puppetter. To avoid problems in places like Cloudflare",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "By Nokersoftware | nokersoft.com",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "chromium": "^3.0.3",
14
+ "sync-request": "^6.1.0"
15
+ }
16
+ }