Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

+1. Thanks for the hints about Selenium.

My 2c about scraping - when you try to obtain data from large websites, always go for javascript content. Pages like Newegg or Amazon * may change html outline very often even without a single alteration to the front-user and even your smartest regex can have a brain fart. In contrast, even when site gets major overhaul, most likely old javascript will be left in place with all up to date variables, because engineers will be concerned of removing that code not to break some functionality .

* given you have rights to scrap.

not that there are no tools to debug the site; but I found websites like mentioned plus youtube, and bunch others just not fiddling too much with js.



> even your smartest regex can have a brain fart

If you're using regex to solve this sort of problem, your code deserves to break, I'm sorry.


I've found that regex is very brittle when you don't control what comes across. DOM traversal is far more reliable.


Agree... basically search methods that specify a branch or leaf locally rather than the entire tree structure can more often resist layout changes.

Regex for HTML is a bad idea ... http://stackoverflow.com/questions/590747/using-regular-expr...


Parsing arbitrary HTML is not the same as scraping a page for data -- that link isn't really that relevant.


Good point. I simply avoided regex for HTML for this reason and it wasn't justified (although a good choice).


This. You usually traverse the DOM. Either you use some XQuery /XPath magic or a library like beautiful soup.


Sizzle for life.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: