logoalt Hacker News

gulugawayesterday at 8:55 PM2 repliesview on HN

I've had luck blocking scrapers by overwriting JavaScript methods

" a.getElementsByTagName = function (...args) {//Clear page content}"

One can also hide components inside Shadow DOM to make it harder to scrape.

However, these methods will interfere with automated testing tools such as Playwright and Selenium. Also, search engine indexing is likely to be affected.


Replies

TurdF3rgusonyesterday at 9:46 PM

You think you've had luck. The truth is you have no idea of knowing if this ever had any effect at all.

bogwogyesterday at 9:39 PM

This is a fun idea, especially if you make those functions procedurally generate garbage to get them stuck