Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript load document without rendering

My apologies if this is a stupid question, but I spent hours searching with no results.

I would like to look at the raw HTML of a document without it being rendered by the browser. Is there a DOM element that does this; or a method that disables rendering?

It's for a dumbed-down search engine that flips through a bunch of URLs looking for a particular character pattern.

I could use an iframe and then look at iframe.innerHTML but that slows things down and creates too much traffic as the browser loads ads and images.

The document sources are all over the web so AJAX is not on. PHP is a last resort.

like image 954
John McKean Avatar asked Aug 29 '26 09:08

John McKean


1 Answers

The Same origin policy prevents this in the browser. It will only work if you fetch the html from the domain that your Javascript code is on.

PHP has a file_get_contents function that lets you do this.

like image 77
Matt Zeunert Avatar answered Aug 31 '26 00:08

Matt Zeunert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!