Graby\Extractor\ContentExtractor::getTitle PHP Method

getTitle() public method

public getTitle ( )
    public function getTitle()
    {
        return trim($this->title);
    }

Usage Example

Beispiel #1
0
 /**
  * Test that if the first h* found in the body is the same as the extracted title, it'll be removed.
  */
 public function testRemoveH1FromBody()
 {
     $contentExtractor = new ContentExtractor(self::$contentExtractorConfig);
     $config = new SiteConfig();
     $config->body = array('//div');
     $config->title = array('//title');
     $res = $contentExtractor->process('<html><body><title>My Title</title><div><h3>My Title</h3>' . str_repeat('this is the best part of the show', 10) . '</div></body></html>', 'https://lemonde.io/35941909', $config);
     $this->assertTrue($res, 'Extraction went well');
     $domElement = $contentExtractor->getContent();
     $content = $domElement->ownerDocument->saveXML($domElement);
     $this->assertNotContains('My Title', $content);
     $this->assertEquals('My Title', $contentExtractor->getTitle());
 }