elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  RSS Feed para las noticias con PHP
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: RSS Feed para las noticias con PHP  (Leído 1,922 veces)
erikcatala

Desconectado Desconectado

Mensajes: 177



Ver Perfil
RSS Feed para las noticias con PHP
« en: 3 Febrero 2014, 12:29 pm »

He hecho un RSS Feed con PHP para las noticias, funciona todo bien pero tengo 2 dudas.

La carga de la web es lentísima y el RSS  solo hay 20 entradas. Hay alguna manera de aumentar la velocidad de carga y las entradas del RSS?

Código
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  2.  
  3. <?php
  4. $rss = new DOMDocument();
  5. $rss->load('http://www.foro-nexus.com/syndication.php?fid=4');
  6. $feed = array();
  7. foreach ($rss->getElementsByTagName('item') as $node) {
  8. $item = array (
  9. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  10. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  11. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  12. );
  13. array_push($feed, $item);
  14. }
  15.  
  16. echo '<center><img src="http://www.foro-nexus.com/images/Logo-Tutos.png" alt="Foro-Nexus"></center>';
  17. echo '<br>';
  18. echo '<center><h1> Noticias en general</h1></center>';
  19.  
  20. $limit = 5;
  21. for($x=0;$x<$limit;$x++) {
  22. $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  23. $link = $feed[$x]['link'];
  24. $date = date('d/m/Y - H:i:s', strtotime($feed[$x]['date']));
  25. echo '<center><p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br /></center>';
  26. echo '<center style="margin-top: -15px;"><small ><em>Publicado el: <b>'.$date.'</b></em></small></p></center>';
  27.  
  28. }
  29.  
  30.  
  31. $rss = new DOMDocument();
  32. $rss->load('http://www.foro-nexus.com/syndication.php?fid=208');
  33. $feed = array();
  34. foreach ($rss->getElementsByTagName('item') as $node) {
  35. $item = array (
  36. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  37. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  38. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  39. );
  40. array_push($feed, $item);
  41. }
  42.  
  43. echo '<center><h1> Noticias Nexus</h1></center>';
  44.  
  45. $limit = 5;
  46. for($x=0;$x<$limit;$x++) {
  47. $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  48. $link = $feed[$x]['link'];
  49. $date = date('d/m/Y - H:i:s', strtotime($feed[$x]['date']));
  50. echo '<center><p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br /></center>';
  51. echo '<center style="margin-top: -15px;"><small><em>Publicado el: <b>'.$date.'</b></em></small></p></center>';
  52.  
  53. }
  54.  
  55. $rss = new DOMDocument();
  56. $rss->load('http://www.foro-nexus.com/syndication.php?fid=89');
  57. $feed = array();
  58. foreach ($rss->getElementsByTagName('item') as $node) {
  59. $item = array (
  60. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  61. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  62. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  63. );
  64. array_push($feed, $item);
  65. }
  66.  
  67. echo '<center><h1> Noticias Android</h1></center>';
  68.  
  69. $limit = 5;
  70. for($x=0;$x<$limit;$x++) {
  71. $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  72. $link = $feed[$x]['link'];
  73. $date = date('d/m/Y - H:i:s', strtotime($feed[$x]['date']));
  74. echo '<center><p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br /></center>';
  75. echo '<center style="margin-top: -15px;"><small><em>Publicado el: <b>'.$date.'</b></em></small></p></center>';
  76.  
  77. }
  78.  
  79. $rss = new DOMDocument();
  80. $rss->load('http://www.foro-nexus.com/syndication.php?fid=101');
  81. $feed = array();
  82. foreach ($rss->getElementsByTagName('item') as $node) {
  83. $item = array (
  84. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  85. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  86. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  87. );
  88. array_push($feed, $item);
  89. }
  90.  
  91. echo '<center><h1> Noticias Linux</h1></center>';
  92.  
  93. $limit = 5;
  94. for($x=0;$x<$limit;$x++) {
  95. $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  96. $link = $feed[$x]['link'];
  97. $date = date('d/m/Y - H:i:s', strtotime($feed[$x]['date']));
  98. echo '<center><p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br /></center>';
  99. echo '<center style="margin-top: -15px;"><small><em>Publicado el: <b>'.$date.'</b></em></small></p></center>';
  100.  
  101. }
  102.  
  103. $rss = new DOMDocument();
  104. $rss->load('http://www.foro-nexus.com/syndication.php?fid=173');
  105. $feed = array();
  106. foreach ($rss->getElementsByTagName('item') as $node) {
  107. $item = array (
  108. 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  109. 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  110. 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  111. );
  112. array_push($feed, $item);
  113. }
  114.  
  115. echo '<center><h1> Noticias FireFox</h1></center>';
  116.  
  117. $limit = 5;
  118. for($x=0;$x<$limit;$x++) {
  119. $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
  120. $link = $feed[$x]['link'];
  121. $date = date('d/m/Y - H:i:s', strtotime($feed[$x]['date']));
  122. echo '<center><p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br /></center>';
  123. echo '<center style="margin-top: -15px;"><small><em>Publicado el: <b>'.$date.'</b></em></small></p></center>';
  124.  
  125. }
  126.  
  127. ?>

En mi web esta subido: http://getmoneyfuckbitches.uni.me/pruebas/


« Última modificación: 3 Febrero 2014, 13:12 pm por @drvy » En línea

erikcatala

Desconectado Desconectado

Mensajes: 177



Ver Perfil
Re: RSS Feed para las noticias con PHP
« Respuesta #1 en: 3 Febrero 2014, 12:47 pm »

Me acabo de dar cuenta que el time H que seria la hora en formato 24 muestra un valor raro, no es la hora... :S


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines