From db0faf02d434e055148e461aae7954392398aca0 Mon Sep 17 00:00:00 2001 From: bastien ollier Date: Fri, 2 Dec 2022 09:36:04 +0100 Subject: [PATCH] add parseur flux rss --- RssParser.php | 31 +++++++++++++++++++++++++++++++ appel.php | 23 +++++++++++++++++++++++ news.php | 1 + sources.php | 1 - 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 RssParser.php create mode 100644 appel.php diff --git a/RssParser.php b/RssParser.php new file mode 100644 index 0000000..dd0a17b --- /dev/null +++ b/RssParser.php @@ -0,0 +1,31 @@ +channel->item as $item) + { + $title = $item->title; + $description = $item->description; + $pubdate = $item->pubDate; + $link = $item->link; + $listeArticles[] = new News($title,$description,$pubdate,$link); + + // Create summary as a shortened body and remove images, + // extraneous line breaks, etc. + //$post->summary = $this->summarizeText($post->text); + } + + return $listeArticles; + } +} +?> diff --git a/appel.php b/appel.php new file mode 100644 index 0000000..c2cf883 --- /dev/null +++ b/appel.php @@ -0,0 +1,23 @@ + + +getResultFlux("https://www.lemonde.fr/sciences/rss_full.xml"); +foreach($resultFlux as $n){ + echo $n->getTitle(); + echo "
"; + echo $n->getPubdate(); + echo "
"; + echo $n->getLink(); + echo "
"; + echo $n->getDescription(); + echo "
"; + echo "
"; +} + +?> + + diff --git a/news.php b/news.php index dacfb9b..ad0ddec 100644 --- a/news.php +++ b/news.php @@ -1,4 +1,5 @@ link; } - } ?>