Supprimmer tout avant une zone définie

Résolu
Also know as Messages postés 259 Date d'inscription samedi 13 décembre 2003 Statut Membre Dernière intervention 22 novembre 2010 - 17 févr. 2007 à 09:59
vilhjalms Messages postés 591 Date d'inscription mercredi 20 juillet 2005 Statut Membre Dernière intervention 16 juillet 2009 - 18 févr. 2007 à 00:43
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 "

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.
Quelqu'un aurait-il une idée s'il vous plait

5 réponses

vilhjalms Messages postés 591 Date d'inscription mercredi 20 juillet 2005 Statut Membre Dernière intervention 16 juillet 2009 2
17 févr. 2007 à 13:21
Saell og blesuð

<?php

$url= 'http://www.allocine.fr/film/fichefilm_gen_cfilm=5032.html';

$url_handle = fopen($url, "rb");
$url_contents = '';
while (!feof($url_handle)) {
  $url_contents .= fread($url_handle, 8192);
}
fclose($url_handle);

$motif_fr='`<title>(.+?)</title>`';
$motif_vo='`Titre original : (.+?) `';
preg_match($motif_fr,$url_contents,$result_fr);
preg_match($motif_vo,$url_contents,$result_vo);
$title_fr =str_replace(array('<title>','</title>'),array('',''),$result_fr[0]);
$title_vo=str_replace(array('Titre original : ',''),array('',''),$result_vo[0]);

echo $title_fr,'
',$title_vo;

?>


Vilhjálms Sigurðsdóttir aka Frëyjá
3
Also know as Messages postés 259 Date d'inscription samedi 13 décembre 2003 Statut Membre Dernière intervention 22 novembre 2010 2
17 févr. 2007 à 10:07
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'ets 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 ?

Merci
0
Also know as Messages postés 259 Date d'inscription samedi 13 décembre 2003 Statut Membre Dernière intervention 22 novembre 2010 2
17 févr. 2007 à 15:22
Salut merci beaucoup,


Je n'ai pas de quoi le tester de suite mais des que je serais chez moip je vais tester cela.


Merci beaucoup
0
Also know as Messages postés 259 Date d'inscription samedi 13 décembre 2003 Statut Membre Dernière intervention 22 novembre 2010 2
17 févr. 2007 à 22:48
Bon et bien il n'y a rien à dire c'est parfait cela fonctionne parfaitement, c'est clair net et précis !

Merci beaucoup !

@+
0

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

Posez votre question
vilhjalms Messages postés 591 Date d'inscription mercredi 20 juillet 2005 Statut Membre Dernière intervention 16 juillet 2009 2
18 févr. 2007 à 00:43
Saell og blesuð

Merci de valider la reponse via le button "reponse aceeptee". Merci.


Vilhjálms Sigurðsdóttir aka Frëyjá
0
Rejoignez-nous