M
M
maclaud_7772017-03-09 17:55:42
PHP
maclaud_777, 2017-03-09 17:55:42

PHP: str_get_html is not looking for half of the tags, what could be?

Code example

$curl = curl_init('https://myzuka.fm/Song/6141700/Alekseev-Pyanoe-Solntse-Ser-L-Uk-Remix');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_TIMEOUT, 5);
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
        $content = curl_exec($curl);
        $htmlSong = str_get_html($content);

        print_r(count($htmlSong->find('body')));
        exit;

Returns 0, meaning there is supposedly no body tag. The head tag is looking for, the div is looking for. h1 is not searched. I don't understand what the problem is

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maclaud_777, 2017-03-09
@maclaud_777

The html code of the site contained many errors, the simple html dom library could not cope with the task.
Solution: switched to DomCrawler from symfony

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question