Tuesday 26 November 2019

Generate CSS Selector for Puppeteer?

I'm coding a bot using Puppeteer where I created scrapper classes that interact with web pages. The purpose is to have every CSS selectors in one place for better maintainability in case the web site interface changes.At the moment, to select a button on the page I'm doingconst button = await page.$("div > div: not(:first-child) > ul > li > button")I find the CSS selector clumsy written this way. It's error prone when writing such string and I'm wondering if one of you ever used a library to generate such a string in a more reliable way. Something like this for example :div().div({firstChild: false}).ul().li().button()Any suggestions?

Submitted November 27, 2019 at 05:20AM by baboo77777

No comments:

Post a Comment