-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (36 loc) · 1.2 KB
/
index.js
File metadata and controls
43 lines (36 loc) · 1.2 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
import puppeteer from "puppeteer";
const urls = [
"https://emojipedia.org/people/",
"https://emojipedia.org/nature/",
"https://emojipedia.org/food-drink/",
"https://emojipedia.org/activity/",
"https://emojipedia.org/travel-places/",
"https://emojipedia.org/objects/",
"https://emojipedia.org/symbols/",
"https://emojipedia.org/flags/",
];
export const all = async () => {
const browser = await puppeteer.launch({
headless: true,
args: ["--disable-setuid-sandbox"],
"ignoreHTTPSErrors": true
});
const getEmojis = async (browser, url) => {
let page = await browser.newPage();
console.log(`Downloading emojis from ${url}...`);
await page.goto(url);
await page.waitForSelector(".emoji-list");
const emojis = await page.$$eval("ul.emoji-list > li:not(.emo-flow-ad)", links => {
links = links.map(el => el.querySelector("a").textContent);
return links;
});
return emojis;
};
const promises = urls.map(url => getEmojis(browser, url));
const result = await Promise.all(promises);
await browser.close();
return result.flat();
};
export default {
all,
};