Showing 2 changed files with 31 additions and 4 deletions
+25 -2
sources/news-nyt.php
... ...
@@ -2,7 +2,7 @@
2 2
 include_once( 'news-constants.php' );
3 3
 
4 4
 $rss_content = file_get_contents(NEWS_RSS_NYT);
5
-$orgStrings = array( 'media:content');
5
+$orgStrings = array( 'media:thumbnail');
6 6
 $newStrings = array( 'mediacontent');
7 7
 $rss_content  = str_replace($orgStrings, $newStrings, $rss_content);
8 8
 $xml = simplexml_load_string($rss_content);
... ...
@@ -27,7 +27,7 @@ if ($xml === false) {
27 27
     $article['image']=$item->mediacontent['url'];
28 28
     $articles[$cpt] = $article;
29 29
     echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
30
-    echo '<img id="img-list" src="'.$article['image'].'" style="display:block;"><br>';
30
+    echo '<img id="img-list" src="'.$article['image'].'" style="display:inline;"><br>';
31 31
     echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
32 32
     echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
33 33
     echo $article['title'].'&nbsp;&nbsp;';
... ...
@@ -57,13 +57,36 @@ foreach ($articles as $article ) {
57 57
   $doc = new DOMDocument();
58 58
   $doc->preserveWhiteSpace = false;
59 59
   $doc->formatOutput       = true;
60
+  $libxml_previous_state = libxml_use_internal_errors(true);
60 61
   $doc->loadHTML($article_content);
62
+  libxml_clear_errors();
63
+  libxml_use_internal_errors($libxml_previous_state);
61 64
   $articles = $doc->getElementsByTagName('article');
62 65
   $article_only="";
63 66
   foreach ( $articles as $node) {
64 67
     $article_only = DOMinnerHTML($node);
65 68
   }
66 69
   
70
+  $SEARCH_SUB='<span class="ea_article">édition abonné</span>';
71
+  $pos_start=strpos($article_content, $SEARCH_SUB);
72
+  if($pos_start) {
73
+    $article_abonne = str_replace("www.lemonde.fr", "abonnes.lemonde.fr", $article['link']);
74
+    $article_content = file_get_contents($article_abonne);
75
+    $doc = new DOMDocument();
76
+    $doc->preserveWhiteSpace = false;
77
+    $doc->formatOutput       = true;
78
+    $libxml_previous_state = libxml_use_internal_errors(true);
79
+    $doc->loadHTML($article_content);
80
+    libxml_clear_errors();
81
+    libxml_use_internal_errors($libxml_previous_state);
82
+    $articles = $doc->getElementsByTagName('article');
83
+    $article_only="";
84
+    foreach ( $articles as $node) {
85
+      $article_only = DOMinnerHTML($node);
86
+    }
87
+  }
88
+
89
+
67 90
 	//Clean some sections
68 91
 	//$article_only = re_remove($article_only, '//');
69 92
 	$article_only = re_remove($article_only, '/<div id="(.+?)-slug" class="ResponsiveAd-(.+?)"><p>Advertisement<\/p><\/div>/');
+6 -2
sources/news-wapo.php
... ...
@@ -1,7 +1,8 @@
1 1
 <?php
2 2
 include_once( 'news-constants.php' );
3 3
 
4
-$rss_content = file_get_contents(NEWS_RSS_WAPO);
4
+//$rss_content = file_get_contents(NEWS_RSS_WAPO);
5
+$rss_content = file_get_contents('https://sg.kawi.fr/feed-wapo.xml');
5 6
 $orgStrings = array( 'media:thumbnail');
6 7
 $newStrings = array( 'mediacontent');
7 8
 $rss_content  = str_replace($orgStrings, $newStrings, $rss_content);
... ...
@@ -58,7 +59,10 @@ foreach ($articles as $article ) {
58 59
   $doc = new DOMDocument();
59 60
   $doc->preserveWhiteSpace = false;
60 61
   $doc->formatOutput       = true;
62
+  $libxml_previous_state = libxml_use_internal_errors(true);
61 63
   $doc->loadHTML($article_content);
64
+  libxml_clear_errors();
65
+  libxml_use_internal_errors($libxml_previous_state);
62 66
   $articles = $doc->getElementsByTagName('article');
63 67
   $article_only="";
64 68
   foreach ( $articles as $node) {
... ...
@@ -71,7 +75,7 @@ foreach ($articles as $article ) {
71 75
   echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
72 76
   echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
73 77
   echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
74
-  echo '<div class="extract-content" id="'.$cpt.'">'."<h1>".$article['title']."</h1>".$article_only.'</div>';
78
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
75 79
   echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
76 80
   echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
77 81
   echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';