-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_clone.js
57 lines (52 loc) · 1.62 KB
/
_clone.js
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
import scrape from "website-scraper";
import PuppeteerPlugin from "website-scraper-puppeteer";
import path from "path";
import { dirname } from "dirname-filename-esm";
import { CookieJar } from "tough-cookie";
import * as fs from "node:fs/promises";
const rawJson = await fs.readFile(
path.resolve(dirname(import.meta), "designmodo.com.cookies.json"),
"utf-8"
);
const cookies = JSON.parse(rawJson);
const _cookies = cookies.reduce((acc, { name, value }) => {
acc[name] = value;
return acc;
}, {});
console.log(JSON.stringify(_cookies, null, 2));
// const cookieJar = new CookieJar();
// for (const { name, value } of cookies) {
// await cookieJar.setCookie(`${name}=${value}`, "https://designmodo.com");
// }
async function main() {
await scrape({
urls: [
// "https://designmodo.com/startup/app/preview.php?id=30746",
// "https://designmodo.com/startup/app/preview.php?id=30764",
"https://designmodo.com/startup/app/preview.php?id=33891"
],
directory: path.resolve(dirname(import.meta), "cloned"),
request: {
// cookieJar,
// cookies: _cookies,
},
plugins: [
new PuppeteerPlugin({
launchOptions: {
headless: false,
executablePath:
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
args: [
`--user-data-dir=${path.resolve(
dirname(import.meta),
"chrome-user-data"
)}`,
],
} /* optional */,
scrollToBottom: { timeout: 10000, viewportN: 10 } /* optional */,
blockNavigation: true /* optional */,
}),
],
});
}
main();