fetchContent() 공개 메소드

Fetch content from the given url and return a readable content.
public fetchContent ( string $url ) : array
$url string
리턴 array With keys html, title, url & summary
예제 #1
0
파일: GrabyTest.php 프로젝트: harikt/graby
 /**
  * @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']);
 }
예제 #2
0
 public static function fetchURL($url)
 {
     $graby = new Graby();
     try {
         $r = $graby->fetchContent($url);
         return $r;
     } catch (Exception $e) {
     }
 }