-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.example.js
More file actions
57 lines (46 loc) · 1.4 KB
/
test.example.js
File metadata and controls
57 lines (46 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const Linkout = require("linkout-scraper");
const puppeteer = require("puppeteer-extra");
const dotenv = require("dotenv");
dotenv.config();
// add stealth plugin and use defaults (all evasion techniques)
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
puppeteer.use(StealthPlugin());
(async () => {
const browser = await puppeteer.launch({
args: ["--no-sandbox"],
headless: true,
executablePath: "/usr/bin/google-chrome-stable",
});
const page = await browser.newPage();
const cdp = await page.target().createCDPSession();
await page.setViewport({
width: 1440,
height: 900,
});
// add ghost-cursor for maximum safety
await Linkout.tools.loadCursor(page, false);
// remove webdriver detection
await page.evaluateOnNewDocument(() => {
delete navigator.__proto__.webdriver;
});
await Linkout.tools.setUserAgent(page, process.env.USER_AGENT);
const { token } = await Linkout.services.loginWithEmail(page, cdp, {
user: process.env.EMAIL,
password: process.env.PASSWORD,
});
await page.setCookie({
name: "li_at",
value: token,
httpOnly: true,
secure: true,
sameSite: "None",
priority: "Medium",
path: "/",
domain: ".linkedin.com",
});
const comments = await Linkout.services.comments(page, cdp, {
user: "https://www.linkedin.com/in/arshiya-mankar-1158a11a5/",
count: 2,
});
console.log(comments);
})();