简体   繁体   English

如何从外部网站创建内容的RSS提要

[英]How do I create an RSS feed of content from an external website

How can I turn the content of a website into an RSS feed? 如何将网站内容转换为RSS源?

I would also like the feed to be updated every 3 to 6 hours? 我还希望每3到6个小时更新一次Feed? Perhaps with a cron job. 也许有一份计划工作。

This is for an external website, not my own. 这是一个外部网站,而不是我自己的。

Have you looked at YQL? 您看过YQL吗?

Yahoo YQL 雅虎YQL

YQL

It is a service offered by Yahoo that could be configure to get the content from a remote site for you. 这是Yahoo提供的一项服务,可以将其配置为从您的远程站点获取内容。

You would then need to run the script on a cron if you wanted to grab the data regularly. 如果要定期获取数据,则需要在cron上运行脚本。

Example from YQL 来自YQL的示例

This query grabs content from CNN based on xpath (Firebug can help you find out the correct xpath query). 查询基于xpath从CNN中获取内容(Firebug可以帮助您找到正确的xpath查询)。

Then returns it as XML, meaning it is easy to read into a script. 然后将其作为XML返回,这意味着很容易将其读入脚本。

Place this where you want to show the rss content in your theme: 将其放置在您想要在主题中显示rss内容的位置:

<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://feeds.feedburner.com/wprecipes', 3); ?>

Replace "http://feeds.feedburner.com/wprecipes" with your feeed and "3" with the number of articles to display. 用您的费用替换“ http://feeds.feedburner.com/wprecipes”,并用要显示的文章数替换“ 3”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM