You need to write a parser in php. It works fine with Yandex, but youtube.com, for example, does not parse.
Code:
include 'curl_query.php'; require_once 'simple_html_dom.php'; $html = curl_get($url1); $dom = str_get_html($html); $cocos = $dom->find('#header'); foreach ($cocos as $coc) { echo $coc->plaintext; } Curl_query.php code:
function curl_get($url, $referer = 'https://www.google.ru') { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); return $data; } Mistake:
Fatal error: Uncaught Error: Call to a member function (): C: \ OpenServer \ OSPanel \ domains \ parser \ parcer.php: 39 Stack trace: # 0 {main} thrown in C: \ OpenServer \ OSPanel \ domains \ parser \ parcer.php on line 39
simple_html_dom.php- Yuriy Prokopets$domobject returnsfalse, rather this is due to the fact thatcurldoes not return page content - Yuriy Prokopets