-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtable-generator.js
More file actions
26 lines (22 loc) · 851 Bytes
/
table-generator.js
File metadata and controls
26 lines (22 loc) · 851 Bytes
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
'use strict';
const puppeteer = require('puppeteer');
const fs = require('fs');
const questions = fs.readFileSync("questions.txt", {
encoding: "utf8"
}).split('\n');
(async () => {
for (let i = 0; i < questions.length; i++) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const link = "https://leetcode.com/problems/" + questions[i]
await page.goto(link, {
waitUntil: 'networkidle0'
});
const titleElement = await page.$("#question-title");
const title = await page.evaluate(element => element.textContent, titleElement);
const diffElement = await page.$("[diff]");
const diff = await page.evaluate(element => element.textContent, diffElement);
console.log("|[%s](%s)|[Solution](src/%s)|%s|", title, link, questions[i], diff);
await browser.close();
}
})();