Created
July 21, 2023 17:30
-
-
Save yaasita/23e23cc7c246c7f8a67d52c7ac6a5d4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import fs from "fs"; | |
import { JSDOM } from "jsdom"; | |
const content = fs.readFileSync(process.argv[2], "utf8"); | |
const dom = new JSDOM(content); | |
const res = dom.window.document.querySelectorAll("#maincontent article"); | |
let result = []; | |
for (const r of res) { | |
const body = r.querySelector("section").innerHTML; | |
const resban = r.querySelector(".postid").textContent; | |
const date = r.querySelector(".date").textContent; | |
const username = r.querySelector(".postusername").textContent; | |
result.push({ | |
body: body, | |
resban: resban, | |
date: date, | |
username: username, | |
}); | |
} | |
fs.writeFileSync(process.argv[3], JSON.stringify(result, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment