|
La Communauté Webmaster 
| Pages: [1] |
 |
|
|
|
Auteur |
Sujet: Recupéré code source page file_get_contents() (Lu 2109 fois) |
|
 |
Recupéré code source page file_get_contents()
« sur: le 10-04-2010 a 11:08:37 » |
|
|
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #1 sur: le 13-04-2010 a 17:18:20 » |
|
souifi
Membre récent

Hors-Ligne
Messages: 25

Je suis un lama!
|
le site fait des requêtes ajax sur http://www.jeuxvideo.fr/fiche/fiche_v2_ajax.php/fiche/fiche_v2_ajax.php et en POST.
il te faudra donc beaucoup de traitement... par exemple sur ton premier file_get_contents il faudra récuperer l'id qui t'intéresse, puis effectuer une requete en post sur fiche_v2_ajax.php, analyse le site, les pages javascript pour voir les différents paramètre que tu peut envoyer par post...
Je t'ai fait un petit bout de code pour t'aiguiller, celui ci récupère la config minimum pour la plateforme pc du jeux Assassin's Creed 2.
<?php header('Content-type: text/html; charset=utf-8'); function getFicheTechnique($url, $data = array()) { // Génère une chaîne de requête en encodage URL $data = http_build_query($data);
// Crée un contexte de flux $context_options = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data ) ); $context = stream_context_create($context_options);
// Lit tout un fichier dans une chaîne $page = file_get_contents($url, false, $context); // trie du resultat if(preg_match('#config_minimale\'\)\.html\("<div>(.*)</div>"\)#is', $page, $pattern)) { // On retourne un tableau return explode('</div><div>', $pattern[1]); } }
// Exemnple pour Assassin's Creed 2 et la fiche technique PC $url = 'http://www.jeuxvideo.fr/fiche/fiche_v2_ajax.php/fiche/fiche_v2_ajax.php'; $data = array('id'=>'12108'); echo '<h1>Assassin\'s Creed 2: Configuration minimale pour PC</h1>'; $confMinimale = getFicheTechnique($url, $data); foreach($confMinimale as $k => $v) { echo $v . '<br />'; } ?> |
|
En espérant que sa puisse t'aider, bonne chance. |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #2 sur: le 13-04-2010 a 20:35:16 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #3 sur: le 13-04-2010 a 21:44:11 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #4 sur: le 13-04-2010 a 21:55:33 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #5 sur: le 13-04-2010 a 21:58:33 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #6 sur: le 13-04-2010 a 22:00:03 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #7 sur: le 13-04-2010 a 22:04:08 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #8 sur: le 13-04-2010 a 22:05:35 » |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #9 sur: le 14-04-2010 a 23:19:54 » |
|
souifi
Membre récent

Hors-Ligne
Messages: 25

Je suis un lama!
|
Voila, un peut bordélique et lent , mais fonctionnel...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>...</title> </head>
<body> <form action="jeux.php" method="POST"> <input type="text" name='search' /> <input type="submit" /> </form><br /><br /> <?php function formatSearch($string){ $search = array ('@[éèêëÊË]@i','@[àâäÂÄ]@i','@[îïÎÏ]@i','@[ûùüÛÜ]@i','@[ôöÔÖ]@i','@[ç]@i','@[^a-zA-Z0-9]@'); $replace = array ('e','a','i','u','o','c','-'); return preg_replace($search, $replace, $string); }
if(isset($_POST['search']) && !empty($_POST['search'])) { $search = formatSearch($_POST['search']); // On démare une boucle au cas ou il y aurait plusieurs pages while($search) { $page = isset($pageSuivante) ? 'http://www.jeuxvideo.fr/r/' . $search . '/jeu/' . $pageSuivante :'http://www.jeuxvideo.fr/r/' . $search . '/jeu/'; $resultSearch = file_get_contents($page); // On reduit le bloc de recherche à ce qui nous interesse if(preg_match('#name=\'jeu\'(.*)colonne_widgets#Uis', $resultSearch, $pattern)) { $resultSearch = $pattern[1]; // Pour chaque bloc de resultat if(preg_match_all('#conteneur_resultat(.*)<span class=\'date\'>#Uis', $resultSearch, $matches)) { foreach($matches[1] as $v) { // Si il existe une plateforme PC if(preg_match("#href='/jeux/(.*)/(?:\#\w+)?' class(?:.*)<b>(.*)<span(.*)support pc(?:.*)</div>#Uis", $v, $pattern)) { echo '<a href="jeux.php?jeux=' . urlencode($pattern[1]) . '">' . $pattern[2] . '</a><br />'; $i = 1; } } } } // On récupere la pages suivante if(preg_match('#<div class=\'textsuiv\'>(?:.*)([0-9]\.html)(?:.*)</div>#Uis', $resultSearch, $pattern)) $pageSuivante = $pattern[1]; // Sinon on sort de la boucle else break; } if(!isset($i)) echo 'Aucun jeux trouvé.'; }
if(isset($_GET['jeux']) && !empty($_GET['jeux'])) { // On récupere l'ID de la plateform PC if(preg_match("#tab_pf\['pc'\] = (\d+);#Uis", file_get_contents('http://www.jeuxvideo.fr/jeux/' . $_GET['jeux'] . '/#pc'), $pattern)) { $data = array('id' => $pattern[1]); $data = http_build_query($data); // Crée un contexte de flux $context_options = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data ) ); $context = stream_context_create($context_options); // Lit tout un fichier dans une chaîne $page = file_get_contents('http://www.jeuxvideo.fr/fiche/fiche_v2_ajax.php/fiche/fiche_v2_ajax.php', false, $context); // trie du resultat if(preg_match('#config_minimale\'\)\.html\("<div>(.*)</div>"\)#Uis', $page, $pattern)) { // explode parceque j'ai envie $confMinimale = explode('</div><div>', $pattern[1]); // on affiche la config foreach($confMinimale as $k => $v) { echo $v . '<br />'; } } else echo '"jeuxvideo.fr" ne posséde aucune information sur la configuration minimal de ce jeu.'; } } ?> </body> </html> |
| |
|
|
|
|
 |
Re:Recupéré code source page file_get_contents()
« Répondre #10 sur: le 15-04-2010 a 00:10:39 » |
|
|
|
|
| Pages:
[1] |
|
|
|
| |
|
|