How can I get the web page size programmatically?

1.4k Views Asked by At

Is there a way to get web page size using php or javascript ? I want to do this for 100s of domain.

Edit I am not sure what it means enter image description here Thanks

2

There are 2 best solutions below

0
On

You could use file_get_contents() and then simply read the byte size of the result. There are also online tools which you can make a use of their APIs.

Also note, file_get_content() will simply get the content of the webpage as string, that is being said, if you are wanting to get the size including images and etc then you can use something like http://php.net/manual/en/function.stream-get-contents.php

4
On

if you don't need the page don't use file_get_contents() you transfer the whole file for nothing.

instead use

get_headers ( string $url [, int $format = 0 ] )

then just extract the Content-Length

UPDATE- for checking if its changed use the above then compare Last-Modified