/    Sign up×
Community /Pin to ProfileBookmark

Display html load time of a external site

I would like to know what would Ilook for to try and find a snippet of full code that would allow me to get the html load time of an external website. My site displays the links of many sites and I would like for it to also display the load time on each of those next it.

On a side note if possible away to also display the country flag for the url also.

I know this is a lot to ask but perhaps someone has sometime and can help out.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@mr_billauthorNov 14.2008 — I am getting closer

[code=php]
<?php

if (!isset($_SESSION['geocountry'])) {
require_once 'geoip.inc';
$gi = geoip_open( 'GeoIP.dat', GEOIP_STANDARD );
$country = geoip_country_code_by_addr( $gi,
$_SERVER['REMOTE_ADDR'] );
$_SESSION['geocountry'] = $country;
}
$country = strtolower($_SESSION['geocountry']);
echo '<img src="png/'.$country.'.png" />';
?>
[/code]


[code=php]
<?php

$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
$url = 'http://www.sample.com';

// initialize curl with given url
$ch = curl_init($url);
// make sure we get the header
curl_setopt($ch, CURLOPT_HEADER, 1);
// make it a http HEAD request
curl_setopt($ch, CURLOPT_NOBODY, 1);
// add useragent
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
//Tell curl to write the response to a variable
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// The maximum number of seconds to allow cURL functions to execute.
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,60);
// Tell curl to stop when it encounters an error
curl_setopt($ch, CURLOPT_FAILONERROR, 1);

$execute = curl_exec($ch);

// Check if any error occured
if(!curl_errno($ch))
{

$total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
echo 'Took ' . $total_time . ' seconds to send a request to ' . $url;
clearstatcache();
}
curl_close($ch);

?>
[/code]


But I need them to work together and cant get it to work. Using the cURL I am not sure which I need to use in order to retrieve html load time right now the current speed seems a bit too quick. I need for the country flag to display for the url the speed check part is checking
×

Success!

Help @mr_bill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...