An error occurred while executing the code:

<?php require_once 'simple_html_dom.php'; $content = file_get_contents('http://lineageii.uz/index.php?f=stat&act=general&sid=1'); $dom = new DomDocument; $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); $xpath = new DomXPath($dom); $hel = $xpath->query("//td[@class='l2right']"); echo $hel[2]->nodeValue; ?> 

Displays the result:

 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 64 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 64 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 88 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 88 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 108 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 108 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 111 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 111 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 112 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 112 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 113 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 113 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 114 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 114 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 115 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 115 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): ID lastpost already defined in Entity, line: 150 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): Unexpected end tag : a in Entity, line: 301 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 302 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: no name in Entity, line: 302 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 302 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 Warning: DOMDocument::loadHTML(): Unexpected end tag : size in Entity, line: 324 in C:\WEB\OpenServer\domains\gto\test\test.php on line 5 

What could be a mistake?

  • The error is not in the parser, an error in the document that the parser is trying to parse. What to do? yes, most likely nothing. - KoVadim
  • @KoVadim The fact of the matter is that on a different server, this parser works great! - Arthur Kabirov
  • miracles do not happen. Maybe there is another version of libraries / php or just suppressed warning output - KoVadim
  • @KoVadim suppressed warning output You can talk about this in more detail! - Arthur Kabirov

1 answer 1

Currently there is no statistics available - there is no way to check. But it is not clear that the HTML-ENTITIES error in the code, including in it +, disables errors to the heap. And if the DomDocument is used, what does require_once 'simple_html_dom.php'; ?

Try this code

 $content = file_get_contents('http://lineageii.uz/index.php?f=stat&act=general&sid=1'); $dom = new DomDocument; libxml_use_internal_errors(true); $dom->loadHTML($content); libxml_clear_errors(); $xpath = new DomXPath($dom); $hel = $xpath->query("//td[@class='l2right']"); echo $hel[2]->nodeValue; 

Crackers can occur due to gzip, solution

 $content = file_get_contents('compress.zlib://'.'http://lineageii.uz/index.php?f=stat&act=general&sid=1'); 

or transmit the header Accept-Encoding: deflate, then most give without compression