简体   繁体   English

Google新闻RSS供稿-

[英]Google News RSS Feed -

Trying to get just a text description out of this good news feed, i dont' want the html but i can't find a common way to split it out.. 试图从此好消息提要中仅获取文本描述,我不想要html,但我找不到将其拆分出来的通用方法。

http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=en&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=zh-CN&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss

If you know how to get the HTML data from the right XML-element ( <description> in this case) you can just strip all HTML with PHP's strip_tags 如果您知道如何从正确的XML元素(在本例中为<description>中获取HTML数据,则可以使用PHP的strip_tags剥离所有HTML

This seems to work like you want it: 这看起来像您想要的那样工作:

$news = simplexml_load_file('http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=en&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss');

foreach($news->channel->item as $item) {
    echo $item->title . "\n";
    echo strip_tags($item->description) ."\n";
} 

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

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