Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
CSS vs. XPath for web scraping – SerpApiPodcast (odysee.com)
2 points by ilyazub on Oct 17, 2022 | hide | past | favorite | 3 comments


Why industry tend to use CSS selectors instead of XPath? What is better to select nodes in HTML: CSS selectors or XPath queries?

We discuss these questions in this episode.


What's the verdict?

I've never tried using CSS selectors, but it seems like they would generally be less flexible and able?

XPath seems to have worked well for me.


Selectors are typically more concise and easier for developers to use if they have front end development experience. XPath has marginal benefits over it, like referencing parents/ancestors, but you can often construct a selector to target the elements you want anyways. But since they are so similar, it really comes down to what you work faster with




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: