function devtips_get($url) { $tip = new DevTip(array("url" => $url)); $client = new Client(); $crawler = $client->request('GET', $url); $crawler->filter('div.dt-content')->each(function ($node) use(&$tip) { $html = trim($node->html()); // add line breaks $html = str_replace("><", ">\n<", $html); // remove aside $pos = strpos($html, "<aside"); if ($pos !== false) { $html = substr($html, 0, $pos); } // convert <p>'s to just line breaks $html = str_replace("<p>", "\n", $html); $html = str_replace("</p>", "\n", $html); $tip->set('content', $html); }); $crawler->filter('h3')->each(function ($node) use(&$tip) { $tip->set('title', $node->text()); }); $sources = $crawler->filter('div.dt-content *[src]')->extract(array('src')); $tip->set('assets', $sources); return $tip; }
function devtips_get($url) { $tip = new DevTip(array("url" => $url)); $client = new Client(); $crawler = $client->request('GET', $url); $crawler->filter('div.dt-content')->each(function ($node) use(&$tip) { $html = trim($node->html()); $html = str_replace("><", ">\r\n<", $html); $tip->set('content', $html); }); $crawler->filter('h3')->each(function ($node) use(&$tip) { $tip->set('title', $node->text()); }); $sources = $crawler->filter('div.dt-content *[src]')->extract(array('src')); $tip->set('assets', $sources); return $tip; }