Created
February 7, 2024 04:32
-
-
Save fsndzomga/a8b33c84472de52e264815d1d13bb663 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
const puppeteer = require('puppeteer'); | |
// Custom delay function | |
function delay(time) { | |
return new Promise(function(resolve) { | |
setTimeout(resolve, time); | |
}); | |
} | |
async function countHappyScribeJavaScript(url) { | |
const browser = await puppeteer.launch({ headless: "new" }); | |
const page = await browser.newPage(); | |
await page.goto(url); | |
await delay(2000); | |
const htmlContent = await page.content(); | |
const count = (htmlContent.match(/Happy Scribe/g) || []).length; | |
console.log(`Happy Scribe appears ${count} times.`); | |
await browser.close(); | |
} | |
countHappyScribeJavaScript("https://www.happyscribe.com"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment