$y = date("Y", $t); $m = date("m", $t); $d = date("d", $t); $t1 = "{$d}/{$m}/{$y}"; $t = time(); $y = date("Y", $t); $m = date("m", $t); $d = date("d", $t); $t2 = "{$d}/{$m}/{$y}"; $s = new Scrapper("{$url}/resultados.html", array('post' => array('search' => $nombre, 'desde' => $t1, 'hasta' => $t2))); $primero = true; foreach ($s->query('//*[@id="seccion-arriba"]/article//a') as $a) { $link = $url . $a->attr('href'); $title = $a->text(); $t = new Scrapper($link); $author = $t->node('//li[@class="autor"]')->text(); if (strpos($author, $nombre) !== false) { $content = $t->node('//*[@id="header-noticia"]/h3')->html(); $content .= $t->node('//figure[@id="foto"]')->html(); $content .= $t->node('//div[@itemprop="articleBody"]')->html(); $content = preg_replace('#(?:<br\\s*/?>\\s*?)+#', '</p><p>', $content); $content = preg_replace('#src="/#', 'src="' . $url . '/', $content); $content = preg_replace('#href="/#', 'href="' . $url . '/', $content); $arts[] = new Article($link, $title, $author, $content); } } } return $arts; }; $get_content = function (&$art) { return $art;
function get_content($url) { $s = new Scrapper("http://ftr.fivefilters.org/makefulltextfeed.php?url=" . urlencode($url), array('xml')); return $s->node('//item/description')->text(); }
function py_lanacion() { $y = date("Y", $this->t); $m = date("m", $this->t); $d = date("d", $this->t); $url = 'http://www.lanacion.com.py/category/tapa/'; $s = new Scrapper($url, array('silence')); foreach ($s->query('//article//a') as $a) { if (strpos($a->attr('href'), "{$y}/{$m}/{$d}") !== false) { $s = new Scrapper($a->attr('href'), array('silence')); $img = $s->node('//div[@class="newsstand-blog-single-content"]/p//img')->attr('data-lazy-src'); return '<img src="' . $img . '" style="width:100%;"><br>'; } } }