There is a html page to be parsed. At first I tried to do it using simple html dom, but he refused, since MAX_FILE_SIZE> 600,000 was almost 2 times, he tried to parse with preg_match_all, which in turn works well for the first time, and for the second one it calls Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in Z:\home\localhost\www\parser\1.php on line 50 . Page weighs 1218kb
$html = file_get_contents('source.html'); //$url = "http://46.4.130.245:8080/scripts/grabber/serp-test.php?site=semyadro.pro"; preg_match_all("#span class='big'>(.*?)<#", $html, $loss); $res['poterianie'] = $loss[1][0]; $res['viroschie'] = $loss[1][1]; $res['prosevschie'] = $loss[1][2]; $res['novie'] = $loss[1][3]; preg_match_all('#<div class=\'color_main || medium\'>(.*?)</div>#', $html, $sites);// fatal error here( how to fix? what is the problem?
||are a syntax error andpreg_match_allwill not be executed, but simply return a syntax error. Accordingly, it can not take as much RAM. Give a real regular expression. You can optimize the runtime and memory for this regular expression. It is enough to replace(.*?)<By((?:[^<]++|<)*?)<- ReinRaus||there was a mistake - Dima Morgunov