Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1735 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Récupérer lien de page html avec php

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Récupérer lien de page html avec php

n°1988501
tsunaiken
Posté le 28-04-2010 à 18:26:59  profilanswer
 

salut à tous !!
 
Voila en faite j'ai envie de coder un script en php qui me permettrait de récupérer tout les liens qui se trouve sur n'importe quelle page html !!
 
merci de votre compréhension ,
 
cordialement ,
tsunaiken

mood
Publicité
Posté le 28-04-2010 à 18:26:59  profilanswer
 

n°1988504
flo850
moi je
Posté le 28-04-2010 à 18:40:28  profilanswer
 

et bien je t'en prie, fais le  
quel est le problème ?  
 
je te conseille d'utiliser des expression regulière, mais de toute façon, tu aura du mal arécupérer les liens en flash ainsi que ceux qui sont générés/modifiés en javascript

n°1988505
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-04-2010 à 18:42:19  profilanswer
 

tu preferes pas que je te file le code d'un "google parser" tout fait ?
lol


---------------
http://www.ypikay.com
n°1988506
tsunaiken
Posté le 28-04-2010 à 18:43:24  profilanswer
 

nn mon but et seulement de récupérer les liens qui se trouve sur une page html !!
 
pour cela il faudrait que je sache comment récupérer le code source d'une page mais je n'y arrive pas !!!  
 
merci de votre compréhension

n°1988507
tsunaiken
Posté le 28-04-2010 à 18:44:17  profilanswer
 

google parser ?

n°1988508
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-04-2010 à 18:45:21  profilanswer
 

un code en php qui ouvre un fichier avec des mots clés et va sur google pour choper les liens...
ARFFFFFFFF


---------------
http://www.ypikay.com
n°1988509
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-04-2010 à 18:45:57  profilanswer
 

Ah oui tu n'en es que là !
lol
attends deux secondes je te file ça


---------------
http://www.ypikay.com
n°1988510
tsunaiken
Posté le 28-04-2010 à 18:46:25  profilanswer
 

nn c pas mon but ^^ j'ai quelque chose d'autre a faire avec ces liens

n°1988512
tsunaiken
Posté le 28-04-2010 à 18:46:56  profilanswer
 

mais file quand même ca pourrait minterresser plus tard

n°1988513
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-04-2010 à 18:48:35  profilanswer
 

Voila...
Normalement tu rajoutes juste un petit fichier 'stock.txt' dans lequel tu colles tes mots clés
 
 
 
<?php  
error_reporting(E_ALL ^ E_NOTICE);
?>
<TITLE>000</TITLE>
<?php  
 
//OUVERTURE DU COMPTEUR
 
$compteur = 1;
 
// PAS PLUS SINON GOOGLE EJECTE L'ADRESE IP
while ($compteur < "7" )
{
$compteur++;
 
$i = 2;
 
//OUVERTURE DU STOCKAGE DES MOTS CLES
 
$fichier = fopen("stock.txt",'r');
while ($i < $compteur)
 {
 $i++;
 //RECUPERATION DE LA VARIABLE ET RETRAIT DERNIER CHR QUI CAUSE BUG
 $mc = fgets($fichier, 1024);
 $motcle = $mc;
 
 if ( (substr($mc,0,1) === "é" ) || (substr($mc,0,1) === "è" ) || (substr($mc,0,1) === "ê" ) )
  {
  $motcleinserer = $mc;
  $mc = "e".substr($mc,1);
  }
 
 
 if ( (ord(substr($mc, -1)) < 48) || (ord(substr($mc, -1)) > 122) )
  {
  echo '__'.$mc.'__<br>';
  $mc = substr($mc, 0, -1);
  $motcle = $mc;
  $motcleinserer = $mc;
  }
 if ( (ord(substr($mc, -1)) < 48) || (ord(substr($mc, -1)) > 122) )
  {
  echo '__'.$mc.'__<br>';
  $mc = substr($mc, 0, -1);
  $motcle = $mc;
  $motcleinserer = $mc;
  echo '__'.$mc.'__<br>';
  }
 
 $motcleinserer = str_replace(" ","+",$motcle);
 
 $url_temp = "http://www.google.fr/search?q=".$motcleinserer."&sa=N&num=100&start=000";
 $url = $url_temp;
 }
 fclose($fichier);
//FERMETURE DU STOCKAGE DES URL
 
echo 'URL EN COURS DE LECTURE : '.$url.'<br>';
 
//////////////////////////////////
//////////////////////////////////
//  DEBUT ROUTINE DE RECHERCHE  //
//////////////////////////////////
//////////////////////////////////
 
if (isset($url))
 {
 $lines = file($url);
 foreach ($lines as $line_num => $line)
  {  
  $htmline = htmlentities($line);  
 
  if (strpos($htmline,'a href') !== FALSE)
   {
 
   //DECOMPOSITION DU CODE PRINCIPAL
 
   $htmline  = str_replace("a href", "_A HREF_", $htmline);
   $htmline  = str_replace("&quot;", "_QUOTE_", $htmline);
   $htmline  = str_replace("&gt;", "_GTCRC_", $htmline);
   $htmline  = str_replace("&lt;", "_LTCRC_", $htmline);
   $htmline  = str_replace("&amp;", "_ET_", $htmline);
   $htmline  = str_replace("ET_amp;", "&", $htmline);
   $htmline  = str_replace("A HREF_=_QUOTE_", "_DEBUT_LIEN_", $htmline);
   $htmline  = str_replace("_ET_", "&", $htmline);
 
   $htmline  = str_replace("_LTCRC_span class=tbpo_GTCRC_Masquer les options_LTCRC_/span","", $htmline);
   $tempo = explode('_DEBUT_LIEN_', $htmline);
 
 
   //EXPLORATION AU NIVEAU D'UNE GROSSE LIGNE
 
   $i= 0;
   while ($i < "400" )
    {
    $i++;
 
    // AFFICHAGE DE LA LIGNE
 
    $lienhtml = @explode("_QUOTE_",$tempo[$i]);
 
    //SI ON A GOOGLE DANS LE LIEN ON N'ENREGISTRE PAS
 
 
    if (  (stristr($lienhtml[0],'google') === FALSE)  
     && (stristr($lienhtml[0],'q=http') === FALSE)  
     && (stristr($lienhtml[0],'search?q') === FALSE)
     && (stristr($lienhtml[0],'url?q=') === FALSE)
     && (strpos($lienhtml[0],'youtube') === FALSE)
     && (strpos($lienhtml[0],'search?hl') === FALSE)
     && (stristr($lienhtml[0],'maps.google') === FALSE)
     && (stristr($lienhtml[0],'q=cache') === FALSE)
     && (stristr($lienhtml[0],'img src') === FALSE)
     && (stristr($lienhtml[0],'search?num') === FALSE)
     && (substr($lienhtml[0],0,4) ==="http" ))
 
     {
 
$titre = explode("class=l_GTCRC_",$tempo[$i]);
 
$titre = str_replace("_LTCRC_em_GTCRC_","",$tempo[$i]);
$titre = str_replace($lienhtml[0],"",$titre);
$titre = str_replace("_LTCRC_/em_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_br_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_cite_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_/cite_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_b_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_/b_GTCRC_","",$titre);
$titre = str_replace("_LTCRC_","",$titre);
$titre = str_replace("span class=gl","",$titre);
$titre = str_replace("/a_GTCRC_/h3_GTCRC_div class=_QUOTE_s hc_QUOTE_","",$titre);
$titre = str_replace("valign=top id=mbb4","",$titre);
$titre = str_replace("_QUOTE_ class=l title=_QUOTE_","",$titre);
$titre = str_replace("_QUOTE_ class=l_GTCRC_","",$titre);
 
 
$titre = str_replace("|","-",$titre);
 
 
$titre = str_replace("&auml;","ä",$titre);
$titre = str_replace("&euml;","ë",$titre);
$titre = str_replace("&iuml;","ï",$titre);
$titre = str_replace("&ouml;","ö",$titre);
$titre = str_replace("&uuml;","ü",$titre);
 
$titre = str_replace("&acirc;","â",$titre);
$titre = str_replace("&ecirc;","ê",$titre);
$titre = str_replace("&icirc;","î",$titre);
$titre = str_replace("&ocirc;","ô",$titre);
$titre = str_replace("&ucirc;","û",$titre);
 
$titre = str_replace("&agrave;","à",$titre);
$titre = str_replace("&Agrave;","A",$titre);
$titre = str_replace("&egrave;","è",$titre);
$titre = str_replace("&Egrave;","E",$titre);
$titre = str_replace("&ugrave;","ù",$titre);
 
 
$titre = str_replace("&eacute;","é",$titre);
$titre = str_replace("&Eacute;","E",$titre);
$titre = str_replace("&ccedil;","ç",$titre);
$titre = str_replace("&quot;",'\"',$titre);
$titre = str_replace("&reg;","®",$titre);
$titre = str_replace("&raquo;",'\"',$titre);
$titre = str_replace("&#39;","\'",$titre);
 
$titre = str_replace("&gt;",">",$titre);
$titre = str_replace("&lt;","<",$titre);
 
$positionfintitre = strpos($titre,"/a" );
if ($positionfintitre>0)
 {
 $titre = substr($titre,0,$positionfintitre);
 }
 
////////////////////////////
/// INSERTION TITRE DANS ///
///     BASE_GLOBALE     ///
////////////////////////////
 
if (isset($titre))
{  
$tempotitre = explode(' ',$titre);
 
 if (isset($tempotitre[0]))
 {
 $t = 0;
 while ($t < 15)
  {
  $t++;
  if (stristr($tempotitre[$t],"/a" ) !== FALSE)
   {
   $lastword = $t;
   $tempotitre[$t] = substr($tempotitre[$t],0,strpos($tempotitre[$t],"/a" ));
   }
  }
 }
}
 
$t=-1;
 
if (!isset($lastword))
{
$lastword = 10;
}
 
while ($t < $lastword +1)
 {
 $t++;
 if (  (strlen($tempotitre[$t]) > 3) && (stristr($tempotitre[$t],'_') === FALSE)  )
  {
 
  //CHOIX NOM DE LA BASE EN FONCTION DE LA PREMIERE LETTRE DU MOT
 
$tempotitre[$t] = strtolower($tempotitre[$t]);
 
$tempotitre[$t] = str_replace("l\'","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("d\'","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("n\'","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("m\'","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("j\'","",$tempotitre[$t]);
 
$tempotitre[$t] = str_replace("[","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("]","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("(","",$tempotitre[$t]);
$tempotitre[$t] = str_replace(" )","",$tempotitre[$t]);
$tempotitre[$t] = str_replace(",","",$tempotitre[$t]);
$tempotitre[$t] = str_replace(":","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&middot;","-",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&laquo;","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&curren;","€",$tempotitre[$t]);
$tempotitre[$t] = str_replace('\"',"",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&gt;","-",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&acirc;ble","â",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&ocirc;","ô",$tempotitre[$t]);
$tempotitre[$t] = str_replace("...","",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&ccedil;","ç",$tempotitre[$t]);
$tempotitre[$t] = str_replace("&deg;","°",$tempotitre[$t]);
 
$temp = substr($tempotitre[$t],0,1);
 
/////////////////////////////////
/// MISE A JOUR FICHIER TEXTE ///
/////////////////////////////////
 
 
$mafichebase = 'DICO/'.$tempotitre[$t].'_BASE.csv';
$fichier_base = fopen($mafichebase,'a');
 
fwrite($fichier_base, $lienhtml[0]);
fwrite($fichier_base, "|" );
fwrite($fichier_base, $titre);
fwrite($fichier_base, "\r\n" );
 
fclose($fichier_base);
 
  }
 }
 
////////////////////////////
 
$positionfintitre =0;
 
$positionfintitre = strpos($titre,"/a" );
if ($positionfintitre>0)
 {
 $titre = substr($titre,0,$positionfintitre);
 }
 
$positionfintitre2 =0;
 
$positionfintitre2 = strpos($titre,"_QUOTE_" );
if ($positionfintitre2>0)
 {
 $titre = substr($titre,0,$positionfintitre2);
 }
 
echo '<font size ="2" color ="blue">===>Adresse===>'.$lienhtml[0].'<br></font>';
echo '<font size ="2" color ="red">===>Titre===>'.$titre.'<br></font>';
 
 
//     //CONNEXION A LA BASE DE DONNEES
//     $db="base__";
//     $link = mysql_pconnect("localhost", "pulbot","abcdefgh" );
//     mysql_select_db($db , $link);
//     $commande = " INSERT INTO `$tempotitre[$t]` (`url`, `titre`) VALUES ('$lienhtml[0]','$titre')";
//     $sql = mysql_query($commande);
//     $sql = mysql_query(" DELETE  FROM `$tempotitre[$t]` WHERE `url` NOT LIKE 'http://%'" );
 
     }
    }
 
   }
 
  }
 
 }
}
 
?>  


---------------
http://www.ypikay.com
mood
Publicité
Posté le 28-04-2010 à 18:48:35  profilanswer
 

n°1988514
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-04-2010 à 18:49:03  profilanswer
 

Oups....
J'crois que je me suis laché


---------------
http://www.ypikay.com
n°1988799
tsunaiken
Posté le 29-04-2010 à 16:29:10  profilanswer
 

merci


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Récupérer lien de page html avec php

 

Sujets relatifs
Lien Word 2007 vers ancre HTML[API google Maps javascript] affichage page html dans une infobulle
integrer mumble viewer sur sa page .xml[JAVA-JEE]rafraichissement page JEE
[Résolu] Bug: le texte est gros aléatoirement...image différente depuis une autre page
Page Jsp qui affiche le ${ blabla }[ VBS ] Récupérer une variable dans une page html
Plus de sujets relatifs à : Récupérer lien de page html avec php


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR