使用php通过google新闻rss提要获取Tumbnail
我无法使用以下代码获取tumbnail图像。我需要做什么才能从谷歌rss订阅源中获取tumbnail图像。有人能帮我吗使用php通过google新闻rss提要获取Tumbnail,php,google-news,Php,Google News,我无法使用以下代码获取tumbnail图像。我需要做什么才能从谷歌rss订阅源中获取tumbnail图像。有人能帮我吗 $news = simplexml_load_file('https://news.google.com/news?pz=1&cf=all&ned=en&hl=en&topic=n&output=rss'); $feeds = array(); $i = 0; foreach ($news->channel->item
$news = simplexml_load_file('https://news.google.com/news?pz=1&cf=all&ned=en&hl=en&topic=n&output=rss');
$feeds = array();
$i = 0;
foreach ($news->channel->item as $item)
{
preg_match('~<img[^>]*src\s?=\s?[\'"]([^\'"]*)~i',$item->description, $imageurl);
//preg_match('@src="([^"]+)"@', $item->description, $imageurl);
$parts = explode('<font size="-1">', $item->description);
$feeds[$i]['title'] = (string) $item->title;
$feeds[$i]['link'] = (string) $item->link;
$feeds[$i]['image'] = $imageurl[1];
$feeds[$i]['site_title'] = strip_tags($parts[1]);
$feeds[$i]['story'] = strip_tags($parts[2]);
$i++;
}
echo '<pre>';
print_r($feeds);
echo '</pre>';
$news=simplexml\u加载\u文件('https://news.google.com/news?pz=1&cf=all&ned=en&hl=en&topic=n&output=rss');
$feeds=array();
$i=0;
foreach($news->channel->item as$item)
{
预匹配('~description,$imageurl);
//预匹配('@src=“([^”]+)“@',$item->description,$imageurl);
$parts=分解(“”,$item->description);
$feeds[$i]['title']=(字符串)$item->title;
$feeds[$i]['link']=(字符串)$item->link;
$feeds[$i]['image']=$imageurl[1];
$feeds[$i]['site_title']=strip_标签($parts[1]);
$feeds[$i]['story']=strip_标签($parts[2]);
$i++;
}
回声';
打印(feed);
回声';
缩略图是什么意思?我在提要中没有看到任何这样的属性。@MarkusZeller tumbnails是指新闻图像,您可以在提要中看到它$feeds[$I]['image']=$imageurl[1];
我无法获得任何图像结果。我找不到任何“src”或“img”“上面提要中的字符串=>curl”https://news.google.com/news?pz=1&cf=all&ned=en&hl=en&topic=n&output=rss“-L-s | grep'img\| src'
没有给出任何结果。@Zeitounator问题和问题在于如何获取图像没有图像。你到底想要什么?