I am trying to get HTML content of the page, but when I do that, my file_get_contents only returns piece of JS.
when I use just file_get_contents I can see the content but I am trying to use loadHTML as well. So using the function like below.
function getContent(String $url): \DOMDocument
{
$opts = array(
'http' => array(
'method'=>"GET",
'header'=>"Content-Type: text/html; charset=utf-8"
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url,false,$context);
$parser = new \DOMDocument();
$parser->loadHTML($result = mb_convert_encoding($result,'HTML-ENTITIES', 'ASCII, JIS, UTF-8, EUC-JP, SJIS'));
return $parser;
}
But this time, I am having DOMDocument::loadHTML(): Tag header invalid in Entity
So tried to overcome this problem I used libxml_use_internal_errors(true);
this but, then I am just returning JS part of page...
How can I overcome issue?
The links is here: https://lions-mansion.jp/MF161037/