add listes sources a appel.php

master
Bastien OLLIER 3 years ago
parent a31aa1b419
commit cbad497b4e

@ -1,15 +1,14 @@
<?php
class RssParser
{
public function getResultFlux($url)
{
ini_set('display_errors', 1);
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1');
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1');
$listeArticles = array();
$listeArticles = array();
if (!($x = simplexml_load_file($url)))
if (!($x = simplexml_load_file($url)))
return;
foreach ($x->channel->item as $item)
@ -19,10 +18,6 @@ class RssParser
$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;

@ -1,12 +1,29 @@
<html>
w<html>
<body>
<?php
include("news.php");
include ('RssParser.php');
include("gatewayNews.php");
include("gatewaySources.php");
include ("config.php");
$parser = new RssParser();
$gatewayNew = new gatewayNews($con);
$gatewaySource = new gatewaySources($con);
$listeSources = $gatewaySource->getSources();
foreach($listeSources as $source){
echo $source;
$resultFlux = $parser->getResultFlux($source);
foreach($resultFlux as $n){
$gateNews->addNews($n);
}
}
/*
$resultFlux = $parser->getResultFlux("https://www.lemonde.fr/sciences/rss_full.xml");
foreach($resultFlux as $n){
$gateNews->addNews($n);
echo $n->getTitle();
echo "</br>";
echo $n->getPubdate();
@ -17,7 +34,7 @@ foreach($resultFlux as $n){
echo "</br>";
echo "</br>";
}
*/
?>
</body>
</html>

@ -1,4 +1,5 @@
<?php
include("connection.php");
//préfixe
$rep=__DIR__.'/../';
//BD

Loading…
Cancel
Save