src/Service/Browser.php
public function getContent($path)
    {
        /* @var $response \Guzzle\Http\Message\Response */
        $response = $this->getBrowser()->get($path)->send();
        if ($response->isError()) {
            throw new \RuntimeException('Failed to query the server '.$this->host);
        }
        if ($response->getStatusCode() !== 200 || !($html = $response->getBody(true))) {
            return;
        }
        $html = iconv('windows-1251', 'utf-8', $html);

        // clean content
        $config = [
            'output-xhtml' => true,
            'indent' => true,
            'indent-spaces' => 0,
            'fix-backslash' => true,
            'hide-comments' => true,
            'drop-empty-paras' => true,
            'wrap' => false,
        ];
        $tidy = new \tidy();
        $tidy->parseString($html, $config, 'utf8');
        $tidy->cleanRepair();
        $html = $tidy->root()->value;
        // ignore blocks
        $html = preg_replace('/<noembed>.*?<\/noembed>/is', '', $html);
        $html = preg_replace('/<noindex>.*?<\/noindex>/is', '', $html);
        // remove noembed
        return $html;
    }
public function getContent($path)
    {
        /* @var $response \Guzzle\Http\Message\Response */
        $response = $this->getBrowser()->get($path)->send();
        if ($response->isError()) {
            throw new \RuntimeException('Failed to query the server '.$this->host);
        }
        if ($response->getStatusCode() !== 200 || !($html = $response->getBody(true))) {
            return;
        }
        $html = iconv('windows-1251', 'utf-8', $html);

        // clean content
        $config = [
            'output-xhtml' => true,
            'indent' => true,
            'indent-spaces' => 0,
            'fix-backslash' => true,
            'hide-comments' => true,
            'drop-empty-paras' => true,
            'wrap' => false,
        ];
        $tidy = new \tidy();
        $tidy->parseString($html, $config, 'utf8');
        $tidy->cleanRepair();
        $html = $tidy->root()->value;
        // ignore blocks
        $html = preg_replace('/<noembed>.*?<\/noembed>/is', '', $html);
        $html = preg_replace('/<noindex>.*?<\/noindex>/is', '', $html);
        // remove noembed
        return $html;
    }
public function getContent ( $ path ) { /* @var $response \Guzzle\Http\Message\Response */ $ response = $ this -> getBrowser ( ) -> get ( $ path ) -> send ( ) ; if ( $ response -> isError ( ) ) { throw new \ RuntimeException ( 'Failed to query the server ' . $ this -> host ) ; } if ( $ response -> getStatusCode ( ) !== 200 || ! ( $ html = $ response -> getBody ( true ) ) ) { return ; } $ html = iconv ( 'windows-1251' , 'utf-8' , $ html ) ; // clean content $ config = [ 'output-xhtml' => true , 'indent' => true , 'indent-spaces' => 0 , 'fix-backslash' => true , 'hide-comments' => true , 'drop-empty-paras' => true , 'wrap' => false , ] ; $ tidy = new \ tidy ( ) ; $ tidy -> parseString ( $ html , $ config , 'utf8' ) ; $ tidy -> cleanRepair ( ) ; $ html = $ tidy -> root ( ) -> value ; // ignore blocks $ html = preg_replace ( '/<noembed>.*?<\/noembed>/is' , '' , $ html ) ; $ html = preg_replace ( '/<noindex>.*?<\/noindex>/is' , '' , $ html ) ; // remove noembed return $ html ; }
Get content from path.

Receive content from the URL and cleaning using Tidy

@param string $path

@return string
Get content from path .