Un truc comme ça ? :
<?php
function fetchURL( $url ) {
$url_parsed = parse_url($url);
$host = $url_parsed["host"];
$port = $url_parsed["port"];
if ($port==0)
$port = 80;
$path = $url_parsed["path"];
//if url is
[ Lien ] without final "/"
//I was getting a 400 error
if (empty($path))
$path="/";
//redirection if url is in wrong format
if (empty($host)):
$host="www.pcinpact.com";
$path="/actu/news/La_lutte_antipiratage_sintensifie_en_Angleterre.htm";
endif;
if ($url_parsed["query"] != "")
$path .= "?".$url_parsed["query"];
$out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
fwrite($fp, $out);
$body = false;
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
return $in;
}
fetchURL($address);