- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前正在使用 Simplepie拉入我的 RSS 提要,如下面的配置所示。我想将 $url
移动到我的数据库,因为我的网站加载速度太慢。我将每个 url 作为站点名称的键值对。我想保留此关联,因为我使用例如“abc”将图像从我用于为每个提要设置样式的目录中拉出,正如您在下面的 foreach
循环中看到的那样。
我的问题是,由于我不太清楚数组和表如何协同工作,我将如何重写此脚本以同样方式处理数据库?
我还应该提一下,我已经在 MySQL 中创建了一个表,其中包含行“id”、“name”和“url”。任何澄清都会有所帮助。
<?php
require_once('php/autoloader.php');
$feed = new SimplePie();
// Create a new instance of SimplePie
// Load the feeds
$urls = array(
'http://abcfamily.go.com/service/feed?id=774372' => 'abc',
'http://www.insideaolvideo.com/rss.xml' => 'aolvideo',
'http://feeds.bbci.co.uk/news/world/rss.xml' => 'bbcwn',
'http://www.bing.com' => 'bing',
'http://www.bravotv.com' => 'bravo',
'http://www.cartoonnetwork.com' => 'cartoonnetwork',
'http://feeds.cbsnews.com/CBSNewsMain?format=xml' => 'cbsnews',
'http://www.clicker.com/' => 'clicker',
'http://feeds.feedburner.com/cnet/NnTv?tag=contentBody.1' => 'cnet',
'http://www.comedycentral.com/' => 'comedycentral',
'http://www.crackle.com/' => 'crackle',
'http://www.cwtv.com/feed/episodes/xml' => 'cw',
'http://disney.go.com/disneyxd/' => 'disneyxd',
'http://www.engadget.com/rss.xml' => 'engadget',
'http://syndication.eonline.com/syndication/feeds/rssfeeds/video/index.xml' => 'eonline',
'http://sports.espn.go.com/espn/rss/news' => 'espn',
'http://facebook.com' => 'facebook',
'http://flickr.com/espn/rss/news' => 'flickr',
'http://www.fxnetworks.com//home/tonight_rss.php' => 'fxnetworks',
'http://www.hgtv.com/' => 'hgtv',
'http://www.history.com/this-day-in-history/rss' => 'history',
'http://rss.hulu.com/HuluRecentlyAddedVideos?format=xml' => 'hulu',
'http://rss.imdb.com/daily/born/' => 'imdb',
'http://www.metacafe.com/' => 'metacafe',
'http://feeds.feedburner.com/Monkeyseecom-NewestVideos?format=xml' => 'monkeysee',
'http://pheedo.msnbc.msn.com/id/18424824/device/rss/' => 'msnbc',
'http://www.nationalgeographic.com/' => 'nationalgeographic',
'http://dvd.netflix.com/NewReleasesRSS' => 'netflix',
'http://feeds.nytimes.com/nyt/rss/HomePage' => 'newyorktimes',
'http://www.nick.com/' => 'nickelodeon',
'http://www.nickjr.com/' => 'nickjr',
'http://www.pandora.com/' => 'pandora',
'http://www.pbskids.com/' => 'pbskids',
'http://www.photobucket.com/' => 'photobucket',
'http://feeds.reuters.com/Reuters/worldNews' => 'reuters',
'http://www.revision3.com/' => 'revision3',
'http://www.tbs.com/' => 'tbs',
'http://www.theverge.com/rss/index.xml' => 'theverge',
'http://www.tntdrama.com/' => 'tnt',
'http://www.tvland.com/' => 'tvland',
'http://www.vimeo.com/' => 'vimeo',
'http://www.vudu.com/' => 'vudu',
'http://feeds.wired.com/wired/index?format=xml' => 'wired',
'http://www.xfinitytv.com/' => 'xfinitytv',
'http://www.youtube.com/topic/4qRk91tndwg/most-popular#feed' => 'youtube',
);
$feed->set_feed_url(array_keys($urls));
$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(1800); // Set the cache time
$feed->set_item_limit(1);
$success = $feed->init(); // Initialize SimplePie
$feed->handle_content_type(); // Take care of the character encoding
?>
<?php require_once("inc/connection.php"); ?>
<?php require_once("inc/functions.php"); ?>
<?php include("inc/header.php"); ?>
<?php
// Sort it
$feed_items = array();
// $feed_items is an array
$items = $feed->get_items();
//$items is everything that $items = $feed->get_items(); produces
$urls = array_unique($urls);
// $url = is an empty $
foreach ($urls as $url => $image) {
$unset = array();
$feed_items[$url] = array();
foreach ($items as $i => $item) {
if ($item->get_feed()->feed_url == $url) {
$feed_items[$url][] = $item;
$unset[] = $i;
}
}
foreach ($unset as $i) {
unset($items[$i]);
}
}
foreach ($feed_items as $feed_url => $items) {
if (empty($items)) { ?>
<div class="item element" data-symbol="<?php echo $urls[$feed_url] ?>" name="<?php echo $urls[$feed_url] ?>">
<div class="minimise"><img src="images/boreds/<?php echo $urls[$feed_url] ?>.png"/>
<div class="minimise2">
<a href="<?php echo $feed_url; ?>"><h2>Visit <?php echo $urls[$feed_url] ?> now!</h2></a>
</div></div>
<div class="maximise">
<a href="<?php echo $feed_url; ?>"><h2>Visit <?php echo $urls[$feed_url] ?> now!</h2></a>
</div></div>
<?
continue;
}
$first_item = $items[0];
$feed = $first_item->get_feed();
?>
<?php
$feedCount = 0;
foreach ($items as $item) {
$feedCount++;
?>
<div class="item element" " data-symbol="<?php echo $urls[$feed_url] ?>" name="<?php echo $urls[$feed_url] ?>">
<div class="minimise"><strong id="amount"><?php echo ''.$feedCount; ?></strong>
<img src="images/boreds/<?php echo $urls[$feed_url] ?>.png"/>
<div class="minimise2"><a href="<?php echo $item->get_permalink(); ?>">
<h2><?php echo $item->get_title(); ?></h2></a>
</div></div>
<div class="maximise"><a href="<?php echo $item->get_permalink(); ?>">
<h2><?php echo $item->get_title(); ?></h2></a><br><p><?php echo $item->get_description(); ?></p>
</div></div>
<?php
}
}
?>
<?php require("inc/footer2.php"); ?>
最佳答案
我在一些项目中使用 SimplePie,这就是我为减少页面加载时间所做的工作:我缓存结果。
流程大概是这样的:
feed-fetcher.php
index.html
之类的文件中。事实上,在根文件夹中,我想访问供稿项目内容以便于(或将来)阅读。cron
作业,每 20 分钟左右获取一次提要。.html
文件中。因此,我的页面加载速度非常快,因为我不需要等待获取和处理我想要检查的每个提要。此解决方案不需要任何数据库。但当然,您仍然可以使用数据库将获取的内容以 HTML 格式存储为 string
或适合您需要的任何其他类型。
这是您要找的吗?
关于php - Simplepie RSS 提要到 MySQL 数据库服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11489338/
我正在为现有网站创建 RSS,我只是想知道是否有推荐数量的提要项目显示在 RSS 提要中? 可以输出我想要的任意数量的提要吗?如果需要,一次像 50 个提要一样吗? RSS 的目的是让网站上的订阅者随
从 Windows 命令行,我希望能够发布到 RSS 提要。我想象这样的事情: rsspub @builds "Build completed without errors." 然后,有人可以访问我的
每当我在 RSS 提要中看到图像时,它们都嵌入在 CDATA 中,而不是被标签包围。 在我的提要中,我希望图像不这样做就显示出来。 无论是在浏览器中,还是在提要阅读器 (Bloglines) 中或通过
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
RSS 项目内的描述标签是否有长度限制或最大大小? 此外,此标记是否可以容纳 HTML 标记? 我将生成 和来自同一源 HTML,还想知道 是否标签容纳 HTML。 最佳答案 据我所知,没有长度限制
我正在为我正在开发的网站创建 RSS 提要。我阅读了关于 RSS 的内容,它非常简单:它是一个特殊格式的 XML 文件。 但是,我找不到有关以下两个问题的信息 RSS 提要中的条目/项目数量是否有限制
对于我订阅的所有 RSS 源,我使用 Google Reader ,我喜欢。不过,我确实有几个特定的 RSS 提要,希望在更新后立即收到通知(例如,我希望尽快监控和响应的论坛的 RSS 提要)。
我了解如何制作 RSS 文件。它的 XML 非常简单。但是我需要什么特殊的更新才能分发,还是我只需要定期更新文件而其余的会自行处理?我在 rss 上找到的所有内容都在谈论它的作用,但并没有谈论它是如何
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 8年前关闭。 Improve this qu
是否有任何网站/服务可以让我向任何网站添加 RSS 订阅? 这是我工作的公司。我们有一个显示公司相关新闻的网站。这些新闻由外部机构提供,并自动更新到我们的数据库中。我们的网站选择随机/新消息并显示它们
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我想知道在您的应用程序中使用其他人的 RSS 提要(例如 BBC RSS 提要)是否存在任何法律问题? 最佳答案 你真的应该问律师。但是,我在 out-law.com 上找到了这个: Using a
我们有一个提供一些 RSS 提要的站点,我们想知道有多少人订阅了每个提要,而不使用像 FeedBurner 这样的系统来为他们提供服务。 解决这个问题的原始方法基本上是记录请求,然后获取请求每个提要的
我有一个系统可以获取几百个 RSS 提要。目前,它们的刷新周期为 10 分钟,但我最好让它更快。以近实时/推送间隔获取 RSS 源的策略是什么? 我遇到的一些解决方案: 1分钟取一次;如果没有变化,则
我需要在数据库中存储来自多个 RSS 提要的新项目。我想使用每个项目的 GUID 标记来确定它是否已经存在于数据库中。 见 W3C specification : guid stands for gl
我正在构建一个在线 Rss 阅读器。我希望能够与文章标题和描述一起显示图像。 我正在使用谷歌提要 API 从 CNN ( http://rss.cnn.com/rss/edition.rss ) 读取
我订阅了许多 RSS 提要,主要来自我自己的时区(英国:目前是 GMT+1,又名 BST)。不过我也对新西兰的新闻感兴趣(目前为 GMT+12)。 我的问题是由于我沉迷于需要将未读计数保持在或接近于零
首先,为什么我问:现在 StackOverflow 上的声望点具有真正的值(value)(您可以通过提供赏金将它们花在该死的好答案上)我想监视我可能能够回答的问题并扑向它们! (此外,其他人实时回答我
我想基于我使用的Tumblr标签创建一个RSS feed。我想将的部分提交给博客联合服务。我必须向博客联合组织提供一个RSS feed。但是我不希望所有帖子都出现在那。有什么办法可以做这样的事情吗?
当我们用 rss 阅读器获取 rss 时,阅读器是标记已读/未读状态还是将此类信息发送回服务器? 阅读完一条消息后,我转向另一个 RSS 阅读器,我会收到所有标记为未读的 RSS 记录吗? 最佳答案
我是一名优秀的程序员,十分优秀!