public fetchContent ( string $url ) : array | ||
$url | string | |
return | array | With keys html, title, url & summary |
public function fetchContent($url)
{
$this->logger->log('debug', 'Graby is ready to fetch');
$infos = $this->doFetchContent($url);
$html = $infos['html'];
// filter xss?
if ($this->config['xss_filter']) {
$this->logger->log('debug', 'Filtering HTML to remove XSS');
$html = htmLawed($html, array('safe' => 1, 'deny_attribute' => 'style', 'comment' => 1, 'cdata' => 1));
}
// generate summary
$infos['summary'] = $this->getExcerpt($html);
return $infos;
}
/** * @dataProvider dataForSafeCurl */ public function testBlockedUrlBySafeCurl($url) { $graby = new Graby(); $res = $graby->fetchContent($url); $this->assertCount(8, $res); $this->assertEquals('', $res['language']); $this->assertEquals('', $res['title']); $this->assertEquals('[unable to retrieve full-text content]', $res['html']); $this->assertEquals('[unable to retrieve full-text content]', $res['summary']); $this->assertEquals('', $res['content_type']); $this->assertEquals(array(), $res['open_graph']); $this->assertEquals(500, $res['status']); }