Reputation: 31
I have made a scraper with puppeteer which goes to a website presses Ctrl+A and Ctrl+C and copies the text to a file.
Its a very simple script but it is very annoying that it uses the windows clipboard because if I let the script run in the background I cannot copy and paste anything.
Is there another way to copy the raw text from websites without using the windows clipboard? With raw text I mean all the text which you can see when you visit a website and press Ctrl+A.
Upvotes: 3
Views: 365
Reputation: 25220
You can get the innerText
value from document.body
, which should contain the same (or at least very similar text) to what Ctrl+A, Ctrl+C would give you.
Code Sample
const text = await page.evaluate(() => document.body.innerText);
Upvotes: 1