Graby\Extractor\ContentExtractor::findHostUsingFingerprints PHP Method

findHostUsingFingerprints() public method

It allow to determine if a website is generated using Wordpress, Blogger, etc ..
public findHostUsingFingerprints ( string $html ) : string | false
$html string
return string | false
    public function findHostUsingFingerprints($html)
    {
        foreach ($this->config['fingerprints'] as $metaPattern => $host) {
            if (1 === preg_match($metaPattern, $html)) {
                return $host;
            }
        }
        return false;
    }

Usage Example

Beispiel #1
0
 /**
  * Test if fingerprints are well extract from meta node.
  */
 public function testFingerPrints()
 {
     $contentExtractor = new ContentExtractor(array('config_builder' => array('site_config' => array(dirname(__FILE__)))));
     $res = $contentExtractor->findHostUsingFingerprints('');
     $this->assertFalse($res, 'Nothing host found because empty html');
     $res = $contentExtractor->findHostUsingFingerprints('<html><head><meta name="generator" content="Blogger" /></head></html>');
     $this->assertEquals('fingerprint.blogspot.com', $res);
 }