saurabh  singh
How to find the total number of HTTP requests. ?
By saurabh singh in PHP on Mar 18 2015
  • saurabh  singh
    Mar, 2015 18

    $URL = $argv[1];// Create DOM from URL or file $html = file_get_html($URL);// find all images!! foreach($html->find('img') as $element){$size = get_remote_file_size($element->src);$totalSize = $totalSize + $size; $totalNumResources += 1;/*echo "Total Size So Far: $totalSize.\n"; echo "total resources: $totalNumResources .\n"; echo "IMAGE SIZE: $size.\n";echo "$element->src.\n";*/ }// find all CSS files foreach($html->find('link') as $element) {if (strpos($element->href,'.css') !== false) {$size = retrieve_remote_file_size($element->href);echo "SIZE: $size.\n";$totalSize = $totalSize + $size; $totalNumResources += 1;} }// find all script tags foreach($html->find('script') as $element) {//make sure this is javascriptif (strpos($element->src,'.js') !== false) {$size = get_remote_file_size($element->src);echo " Javascript SIZE: $size.\n"; $totalSize = $totalSize + $size; $totalNumResources += 1;} }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS