Sélectionner une zone bien précise d'un texte

Répondre
Also know as
Also know as
Déconnecté
Bonjour,

Voilà je cherche à pouvoir sélectionner le titre original uniquement.
Je m'explique imaginons j'ai cette page :
http://www.allocine.fr/film/fichefilm_gen_cfilm=5032.html

Je cherche à ne pouvoir sélectionner uniquement : Indiana Jones and the Last Crusade

Donc pour cela je fais cela :

  1. //$link etant le lien : http://www.allocine.fr/film/fichefilm_gen_cfilm=5032.html
  2. $file = $link;
  3. $pagesource = file($file);
  4. while(list($cle,$val) = each($pagesource))
  5. {
  6. //Cette partie me permettant de connaitre le titre en français
  7. if (preg_match("/<title>/i", $val))
  8. {
  9. $patterns[0] = '!<title>!';
  10. $patterns[1] = '!</?title>!';
  11. $replacements[0] = '';
  12. $replacements[1] = '';
  13. echo "TITRE : ".preg_replace($patterns, $replacements, $val);
  14. }
  15. //Et cette partie me permettant de sélectionner le titre original S'IL y'en à un
  16. if (preg_match("/Titre original/i", $val))
  17. {
  18. $patterns[0] = '!Titre original!';
  19. $replacements[0] = 'Mots supplémentaire :';
  20. echo "<br><br>KEYWORDS : ".strip_tags(preg_replace($patterns, $replacements, $val));
  21. }
  22. } 


Donc au final j'obtiens ceci :

TITRE : Indiana Jones et la Dernière Croisade

KEYWORDS : Ce film fait partie de la Saga Indiana JonesDate de sortie : 18 Octobre 1989 Les films sortis à cette date...Réalisé par Steven Spielberg Voir tout le casting...Avec Harrison Ford, Sean Connery, Denholm ElliottFilm américain. Genre : AventureDurée : 2h 7min. Année de production : 1989Mots supplémentaire : : Indiana Jones and the Last CrusadeDistribué par United International Pictures (UIP)

Donc vous l'aurez compris je suis pas loin mais je n'arrive pas à finaliser le script pour que je puisse par exemple supprimer tout ce qu'il y'a avant "Mots supplémentaire" et après le titre original.


Ou alors autre moyen plus simple peut-être voici la ligne contenant le titre original :


  1. </td><td valign="top" width="630" style="padding: 0 0 0 10;"><table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding: 0 0 0 0;"><tr><td valign="top" width="459"><div style="padding:0 0 2 0;"><h4>Ce film fait partie de la <a href="/film/saga_gen_csaga=55.html" class="link1"><b>Saga Indiana Jones</b></a></h4></div><div style="padding: 2 0 2 0; display:inline; width: 80%;"><h4>Date de sortie :<b>18 Octobre 1989</b>&nbsp;&nbsp;&nbsp;<img src="http://a69.g.akamai.net/n/69/10688/v1/img5.allocine.fr/acmedia/skin/allocinev5/puce/fleche_bleue.gif" border="0" style="margin: 0 6 0 0" width="6" height="8" /><a href="/film/agenda_gen_date=18/10/1989.html" class="link1">Les films sortis à cette date...</a></h4></div><div style="padding: 2 0 2 0;"><h4>Réalisé par <a class="link1" href="/personne/fichepersonne_gen_cpersonne=471.html">Steven Spielberg</a></h4><h4>&nbsp;&nbsp;&nbsp;<img src="http://a69.g.akamai.net/n/69/10688/v1/img5.allocine.fr/acmedia/skin/allocinev5/puce/fleche_bleue.gif" border="0" style="margin: 0 6 0 0" width="6" height="8" /><a href="/film/casting_gen_cfilm=5032.html" class="link1">Voir tout le casting...</a></h4></div><div style="padding: 2 0 2 0;"><h4>Avec <a class="link1" href="/personne/fichepersonne_gen_cpersonne=472.html">Harrison Ford</a>, <a class="link1" href="/personne/fichepersonne_gen_cpersonne=1541.html">Sean Connery</a>, <a class="link1" href="/personne/fichepersonne_gen_cpersonne=3449.html">Denholm Elliott</a></h4></div><div style="padding: 2 0 2 0;"><h4>Film américain.&nbsp;</h4><h4>Genre : <a href="/film/alaffiche_genre_gen_genre=13001&genretxt=Aventure.html" class="link1">Aventure</a></h4></div><div style="padding: 2 0 2 0;"><h4>Durée : 2h 7min.&nbsp;</h4><h4>Année de production : 1989</h4></div><div style="padding: 2 0 2 0;"><h4>Titre original : <i>Indiana Jones and the Last Crusade</i></h4></div><div style="padding:2 0 2 0"><h4>Distribué par <a href="/societe/fichesociete_gen_csociete=5078.html" class="link1">United International Pictures (UIP)</a></h4></div></td><td width="155" valign="top"><iframe style="width: 155; height: 1;" src="/monallocine/recommandations/iframefiche.html?typeliste=films&ref=5032&iframename=notesrecos&notepresse=&notepublic=3,707071&ispresortie=0" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000" id="notesrecos" name="notesrecos"></iframe></td></tr></table> 



Pour le titre original c'est le seul étant en italique.
Sachant que je connais cette ligne, et que j'utilise strip_tags pour supprimer les balises HTML, exise t-il un moyen pour que je puisse récupérer le texte se trouvant uniquement enre les balises <i> ?


Quelqu'un aurait-il une idée s'il vous plait ?
Répondre
Accès rapide :

Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Php - Breizh Blog