PHP解析WordPress站点RSS
WordPress默认会在 “网址/feed”上输出RSS ,是一种xml格式。 使用PHP可以进行读取、解析、获得某个部分的内容。如下: $url = "https://www.wpsitedomain.com/feed"; //乱编的rss url,仅供举例 $rss = simplexml_load_file($url, null, LIBXML_NOCDATA); $namespaces = $rss->getNamespaces(true); $posts = $rss->channel->item; foreach($posts as $post){ $title = $post->title; $content = $post->children($namespaces[‘content’])->encoded; $link = $post->link; $category = $post->category; //array $description = $post->description; } ...