public function detail(Response $res) { $title = $res->doc('h1.mhtitle.yahei')->text(); $images = []; $res->doc('ul.mnlt > li#imgshow > img')->each(function (Crawler $node, $i) use(&$images, $res) { $img = $node->attr('src'); if ($img) { $images[] = $img; } }); $this->result(['title' => $title, 'images' => $images]); }
public function detail(Response $res) { $title = $res->doc('#content > h1')->text(); $author = $res->doc('#content > div > div.article > div.topic-content.clearfix > div.topic-doc > h3 > span.from > a')->text(); $images = []; $res->doc('div.topic-content > div.topic-figure.cc img')->each(function (Crawler $node, $i) use(&$images, $res) { $img = $node->attr('src'); if ($img) { $images[] = $img; } }); $this->result(['title' => $title, 'author' => $author, 'images' => $images]); }