I am trying to learn Svelte and for my first App I wanted to learn the webscraping with puppeteer.
I started to watch some videos but I have an issue when I import puppeteer.
Here is the log:
After some researches, I did not find any clues on a solution for this problem. I think I did not understand something from Svelte, Vite or Puppeteer but I don’t know what.
Do you have any idea?
(I am using chrome)
Also, here is the code:
<script>
import puppeteer from "puppeteer"; // The error is due to this line
let url = "some url"
const main = async() => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto(url)
const allArticles = await page.evaluate(() => {
const table = document.querySelector('.table')
const rows = table?.querySelectorAll('tr')
console.log(rows)
})
}
main()
</script>
I did not try anything since I have not found anything about my problem.
I am still trying to find a solution.
Nathan Costantini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Puppeteer runs a local instance of Chromium, you cannot execute it in the browser (e.g. any Svelte code).
Puppeteer is a Node.js library […]