} } exit(W::response($xml, $data, 'news')); break; case 7: $res = bilibili(); $data = array(array('title' => 'Bilibili', 'cover' => $web . '/img/bili/' . mt_rand(0, 10) . '.jpg')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['category'] . ':' . $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link'])); } } exit(W::response($xml, $data, 'news')); break; case 8: $res = yyets(); $data = array(array('title' => '人人影视', 'cover' => $web . '/img/yyets.png')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'cover' => $res[$i]['cover'], 'link' => $res[$i]['link'])); } } exit(W::response($xml, $data, 'news')); break; case 9: $res = songshu(); $data = array(array('title' => '科学松鼠会', 'cover' => $web . '/img/songshu.gif')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link'])); }
<?php header('Content-type:text/html;charset=utf-8'); function yyets() { $data = array(); $url = 'http://www.yyets.com/rss/feed/'; $result = file_get_contents($url); $xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA); for ($i = 0; $i < 6; $i++) { $r = file_get_contents($xml->channel->item[$i]->link); $reg = '#<img[\\s]+src="(http://res\\.yyets\\.com/ftp/.+\\.jpg)"[\\s]+/>#i'; preg_match_all($reg, $r, $matches); array_push($data, array('title' => $xml->channel->item[$i]->title, 'description' => $xml->channel->item[$i]->description, 'cover' => $matches[1][0], 'link' => $xml->channel->item[$i]->link)); } return $data; } print_r(yyets());