
${divContent}
`; console.log(htmlContent); })(); ``` Remember to replace `'https://example.com'` with the target website of your choice. Additionally, modify `'div'` to reflect the specific div element you want to extract the content from. 3. Running the script: Now, in your terminal, navigate to the directory where your `divToText.js` file is located and execute the script using the Node.js runtime environment: ``` node divToText.js ``` After running the script, you will see the extracted div content both as plain text and embedded within HTML p tags. By using Headless Chrome and Puppeteer, you can easily automate the extraction of div content from websites and convert it to different formats, such as plain text or ASCII. This powerful tool greatly simplifies the process, allowing you to efficiently extract the required information for your specific use case.