Last active
January 4, 2023 03:04
-
-
Save manabusakai/e011fde4597c2ea8ca3884c888ea48ff to your computer and use it in GitHub Desktop.
This file contains 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
import jsdom from "jsdom"; | |
const { JSDOM } = jsdom; | |
(() => { | |
const virtualConsole = new jsdom.VirtualConsole(); | |
virtualConsole.sendTo(console, { | |
omitJSDOMErrors: true | |
}); | |
const url = process.argv[2]; | |
const options = { virtualConsole }; | |
JSDOM.fromURL(url, options).then(dom => { | |
const selector = "button.o-noteLikeV3__count"; | |
const targetElement = dom.window.document.querySelector(selector); | |
let likeCount = 0; | |
if (targetElement !== null) { | |
likeCount = targetElement.textContent.match(/[0-9]+/); | |
} | |
console.log(url + "\t" + likeCount); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment