Lire page distante

stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009 - 13 mars 2005 à 21:34
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009 - 20 mars 2005 à 16:37
Salut,

Comment on fait pour lire une page situer sur un serveur different?

J'ai essayer avec file() mais ca ne marche qu'en local!

Merci d'avance

Natsboss

16 réponses

Hades51 Messages postés 36 Date d'inscription mardi 19 octobre 2004 Statut Membre Dernière intervention 23 mars 2005
13 mars 2005 à 21:58
Va voir là tu devrais trouver ton bonheur.http://www.ragestorm.net/tutorial'id=15
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
14 mars 2005 à 19:26
? ce n'est pas en rapport avec du php ca? (j'ai fait une lecture trés rapide....)
0
Hades51 Messages postés 36 Date d'inscription mardi 19 octobre 2004 Statut Membre Dernière intervention 23 mars 2005
14 mars 2005 à 21:51
ca te permet d'executer une page php ou autre qui se trouve sur un serveur distant de facon transparente ( si c'est ce que tu veux faire bien sur :o) ).
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
14 mars 2005 à 21:53
Ben moi en fait c'est de mettre une page, comme si je faisait un
include seulement le include ne marche pas sur une page qui n'est pas
sur mon site....
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Hades51 Messages postés 36 Date d'inscription mardi 19 octobre 2004 Statut Membre Dernière intervention 23 mars 2005
14 mars 2005 à 23:12
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 http://example.com 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);
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
15 mars 2005 à 17:33
En local ca marche par contre sur lycos il me mettent "Fatal error: Maximum execution time of 10 seconds exceeded in..." en clair ca marche pas, snif :'(

D'autre idée?
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
15 mars 2005 à 17:38
Moi voila tout ce qui marche en local mais qui ne marche pas sur
internet: (les differents facon de faire sont separé par les <hr>)

<?php

$url = "www.CEQUEVOUSVOULEZ.com";



$page = file_get_contents($url);

echo $page;



echo "<hr>";



$lines = file ($url);

foreach ($lines as $line_num => $line) {

echo "Ligne No $line_num : " . htmlspecialchars($line) . "
\n";

}





echo "<hr>";



$lines = file ($url);

echo $lines[6];



echo "<hr>";





$data = "";

$fp = file($url);

foreach($fp as $ligne){

$data .=$ligne;

}

print $data;

$fp = file($url);



?>
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
15 mars 2005 à 20:49
upppp please aidez moi
0
Hades51 Messages postés 36 Date d'inscription mardi 19 octobre 2004 Statut Membre Dernière intervention 23 mars 2005
15 mars 2005 à 20:54
moi ça marche nickel sur les pages distantes !!!
tu as essayé mon exemple tel quel et ça marche pas ?
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
15 mars 2005 à 20:59
pas tel quel non car sinon ca me renvoi sur un site qui n'est pas celui que je veux (sur un qui parle de pirate)

Mais pour ta solution, je pense plus que c'est un probleme de mon
hebergeur qui au bout de 10sec de recherche ben il donne l'erreur!
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
16 mars 2005 à 17:14
upppppppp
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
17 mars 2005 à 18:36
please aidez moi, j'en ai vraiment besoin!
0
Hades51 Messages postés 36 Date d'inscription mardi 19 octobre 2004 Statut Membre Dernière intervention 23 mars 2005
18 mars 2005 à 00:16
essayes ca ( mais t'as pas du chercher beaucoup )

http://www.nexen.net/scripts/details.php?scripts=1093
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
18 mars 2005 à 17:20
Oh si j'ai chercher! Sur nexen en particulier!Celui la aussi j'ai essayer!

Voila le code que ça me donne:



<?php

$url1 = "http://meteocentre.com/cgi-bin/get_metar_taf?STN=LFRS";

function alternate_fopen($url , $maxtries=5)

{

$tries = 0;

$redirecting = true;



while ($redirecting && $tries < $maxtries)

{

$tries++;

// get host name and URI from URL, URI not needed though

preg_match("/^(http:\/\/)?([^\/^:]+)([:]?)([^\/]*)([\/]?)(.*)/i", $url,

$matches);

$host = $matches[2];



$port = intval($matches[4]);

if ($port <= 0)

{

$port = 80;

}



$uri = $matches[5].$matches[6];



$connection = fsockopen($host, $port, &$errorNumber, &$errorString,

10);



if ($connection)

{

//tell server what document we want

fputs ($connection, "GET $url HTTP/1.0");

fputs ($connection, "\r\n");

//Host isn't required by HTTP/1.0 but some sites complain otherwise

fputs ($connection, "Host: $host");

fputs ($connection, "\r\n\r\n");



$headerStart = 0;

$headerEnd = 0;

$redirecting = false;

$contents = "";



while (!feof($connection))

{

$currentLine = fgets ($connection, 1024);

if ($headerEnd && $redirecting)

{

break;

}

else if ($headerEnd && !$redirecting)

{

//this is the html from the page

$contents = $contents . $currentLine;

}

else if ( ereg("^HTTP", $currentLine) )

{

//came to the start of the header

$headerStart = 1;

}

else if ( $headerStart && ereg("^[\n\r\t ]*$", $currentLine) )

{

//came to the end of the header

$headerEnd = 1;

}

else

{

//this is the header, if you want it...

if (preg_match("/Location: (.+?)\n/is", $currentLine,

$matches) )

{

//redirects are sometimes relative

$newurl = $matches[1];

if (!preg_match("/http:\/\//i", $newurl, $matches) )

{

$url .= $newurl;

}

else

{

$url = $newurl;

}

//extra \r's get picked up sometimes

//i think only with relative redirects

//this is a quick fix.

$url = preg_replace("/\r/s", "", $url);

$redirecting = true;

}

}

}

}

else

{

return "$errstr ($errno)\n";

}



fclose ($connection);

}

return $contents;

}





alternate_fopen($url1 , $maxtries=5)

?>



Mais ca ne marche toujours pas!

Quelqu'un a une autre idéé où as compris pourquoi ca ne marchait pas?
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
19 mars 2005 à 19:35
Snif.... aidez moi, pourquoi tout ces scripts ne marche pas? Est ce que ca peut etre mon serveur (lycos) qui en est la cause?
0
stanilou Messages postés 193 Date d'inscription mercredi 5 mai 2004 Statut Membre Dernière intervention 18 novembre 2009
20 mars 2005 à 16:37
up
0
Rejoignez-nous