... | ... |
@@ -28,11 +28,15 @@ if ($xml === false) { |
28 | 28 |
//Extract image |
29 | 29 |
$re = '/<img class="size-medium wp-image-(.+?)" src="(.+?)" alt=(.+?)>/'; |
30 | 30 |
preg_match($re, $article['content'], $matches); |
31 |
- $article['image'] = $matches[2]; |
|
32 |
- if ( 0 == strlen($article['image']) ) { |
|
33 |
- $re = '/<img class="aligncenter wp-image-(.+?)" src="(.+?)" alt=(.+?)>/'; |
|
34 |
- preg_match($re, $article['content'], $matches); |
|
31 |
+ if( isset($matches[2]) ) { |
|
35 | 32 |
$article['image'] = $matches[2]; |
33 |
+ if ( 0 == strlen($article['image']) ) { |
|
34 |
+ $re = '/<img class="aligncenter wp-image-(.+?)" src="(.+?)" alt=(.+?)>/'; |
|
35 |
+ preg_match($re, $article['content'], $matches); |
|
36 |
+ $article['image'] = $matches[2]; |
|
37 |
+ } |
|
38 |
+ } else { |
|
39 |
+ $article['image'] = ""; |
|
36 | 40 |
} |
37 | 41 |
|
38 | 42 |
$articles[$cpt]=$article; |
... | ... |
@@ -57,7 +57,10 @@ 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) { |
... | ... |
@@ -72,7 +72,10 @@ foreach ($articles as $article ) { |
72 | 72 |
$doc = new DOMDocument(); |
73 | 73 |
$doc->preserveWhiteSpace = false; |
74 | 74 |
$doc->formatOutput = true; |
75 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
75 | 76 |
$doc->loadHTML($article_content); |
77 |
+ libxml_clear_errors(); |
|
78 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
76 | 79 |
$articles = $doc->getElementsByTagName('article'); |
77 | 80 |
foreach ( $articles as $node) { |
78 | 81 |
$article_only = DOMinnerHTML($node); |
... | ... |
@@ -57,7 +57,10 @@ 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 |
if( isset($articles[0]) ) { |
... | ... |
@@ -82,7 +85,10 @@ foreach ($articles as $article ) { |
82 | 85 |
$doc = new DOMDocument(); |
83 | 86 |
$doc->preserveWhiteSpace = false; |
84 | 87 |
$doc->formatOutput = true; |
88 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
85 | 89 |
$doc->loadHTML($article_content); |
90 |
+ libxml_clear_errors(); |
|
91 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
86 | 92 |
$articles = $doc->getElementsByTagName('article'); |
87 | 93 |
$article_only=""; |
88 | 94 |
if( isset($articles[0]) ) { |
... | ... |
@@ -5,6 +5,7 @@ $rss_content = http_get_contents(NEWS_RSS_LEPOINTFR); |
5 | 5 |
$xml = simplexml_load_string($rss_content); |
6 | 6 |
if ($xml === false) { |
7 | 7 |
echo 'Failed to read RSS'; |
8 |
+ exit(0); |
|
8 | 9 |
} else { |
9 | 10 |
$channel = array(); |
10 | 11 |
$channel['title'] = $xml->channel->title; |
... | ... |
@@ -58,8 +58,10 @@ foreach ($articles as $article ) { |
58 | 58 |
$doc = new DOMDocument(); |
59 | 59 |
$doc->preserveWhiteSpace = false; |
60 | 60 |
$doc->formatOutput = true; |
61 |
- //$doc->loadHTML($article_content); |
|
61 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
62 | 62 |
$doc->loadHTML($article_content_utf8); |
63 |
+ libxml_clear_errors(); |
|
64 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
63 | 65 |
$articles = $doc->getElementsByTagName('article'); |
64 | 66 |
$article_only=""; |
65 | 67 |
foreach ( $articles as $node) { |
... | ... |
@@ -90,7 +90,10 @@ foreach ($articles as $article ) { |
90 | 90 |
$doc = new DOMDocument(); |
91 | 91 |
$doc->preserveWhiteSpace = false; |
92 | 92 |
$doc->formatOutput = true; |
93 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
93 | 94 |
$doc->loadHTML($article_content); |
95 |
+ libxml_clear_errors(); |
|
96 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
94 | 97 |
//$articles = $doc->getElementsByTagName('article_container'); |
95 | 98 |
$articles = $doc->getElementsByTagName('div'); |
96 | 99 |
$article_only=""; |
... | ... |
@@ -69,7 +69,10 @@ foreach ($articles as $article ) { |
69 | 69 |
$doc = new DOMDocument(); |
70 | 70 |
$doc->preserveWhiteSpace = false; |
71 | 71 |
$doc->formatOutput = true; |
72 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
72 | 73 |
$doc->loadHTML($article_content_utf8); |
74 |
+ libxml_clear_errors(); |
|
75 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
73 | 76 |
$articles = $doc->getElementsByTagName('article'); |
74 | 77 |
$article_only=""; |
75 | 78 |
foreach ( $articles as $node) { |
... | ... |
@@ -58,7 +58,10 @@ foreach ($articles as $article ) { |
58 | 58 |
$doc = new DOMDocument(); |
59 | 59 |
$doc->preserveWhiteSpace = false; |
60 | 60 |
$doc->formatOutput = true; |
61 |
+ $libxml_previous_state = libxml_use_internal_errors(true); |
|
61 | 62 |
$doc->loadHTML($article_content); |
63 |
+ libxml_clear_errors(); |
|
64 |
+ libxml_use_internal_errors($libxml_previous_state); |
|
62 | 65 |
$articles = $doc->getElementsByTagName('article'); |
63 | 66 |
$article_only=""; |
64 | 67 |
foreach ( $articles as $node) { |