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

Répondre
Also know as
le 17/02/2007 à 11:59
Also know as
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 :

//$link etant le lien : http://www.allocine.fr/film/fichefilm_gen_cfilm=5032.html
$file = $link;
$pagesource = file($file);
while(list($cle,$val) = each($pagesource))
{
//Cette partie me permettant de connaitre le titre en français
if (preg_match("/<title>/i", $val))
{
$patterns[0] = '!<title>!';
$patterns[1] = '!</?title>!';
$replacements[0] = '';
$replacements[1] = '';
echo "TITRE : ".preg_replace($patterns, $replacements, $val);
}
//Et cette partie me permettant de sélectionner le titre original S'IL y'en à un
if (preg_match("/Titre original/i", $val))
{
$patterns[0] = '!Titre original!';
$replacements[0] = 'Mots supplémentaire :';
echo "<br><br>KEYWORDS : ".strip_tags(preg_replace($patterns, $replacements, $val));
}
}


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 :


</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

Ecrire un message

Votre message vient d'être créé avec succès.
LoadingChargement en cours