是否有任何免费的 php/javascript 库可以帮助将 RSS 提要显示为 html?
最佳答案
在我看来 Simplepie是最好的 RSS 解析器之一。
这是一个例子:
require_once('simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->init();
$feed->handle_content_type();
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<div class="item">
<h2 class="title"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<?php echo $item->get_description(); ?>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach; ?>
关于php - 将 RSS 提要输出为 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2037351/