Fatal error: Maximum execution time of 60 seconds exceeded in \Sunra\PhpSimple\simplehtmldom_1_5\simple_html_dom.php on line 151
My class like this
public function LayHinhTuDong9GagAction($id="aP9QwYV%2CaRjvbnq%2CaOB9wDy")
{
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://9gag.com/?id='.$id.'&c=10',
[
'headers' => [
'referer'=>'https://9gag.com/',
'x-requested-with'=>'XMLHttpRequest',
'method'=>'GET',
'authority'=>'9gag.com',
'path'=>'/?id=aP9QwYV%2CaRjvbnq%2CaOB9wDy&c=10',
'scheme'=>'https',
'accept'=>'application/json, text/javascript, */*; q=0.01',
'accept-encoding'=>'gzip, deflate, br',
'user-agent'=>'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'
]
]
);
$chuoi_dulieu= $res->getBody();
$stringBody = (string) $chuoi_dulieu;
$stringBody=\GuzzleHttp\json_decode($stringBody);
$array_hinh=$stringBody->items;
echo count($array_hinh);
var_dump($array_hinh);
foreach($array_hinh as $key=>$hinh){
$la_video=0;
$dom = HtmlDomParser::str_get_html( $hinh );
$tua_de=$dom->find("h2",0)->plaintext;
$elems = $dom->find("source");
if(empty($elems))// xử lý khi là hình gif mp4 video
{
$elems_2 = $dom->find("div[class=badge-video-container]");
if(!empty($elems_2)){
if($elems_2[0]->{'data-video-source'}=="YouTube"){
echo "YouTube";
continue;
}
}
}else
{
$link_video=$elems[0]->src;;
$link_hinh=preg_replace('/460(\w*)/', "700b", $elems[0]->src);
$link_hinh=str_replace("mp4","jpg",$link_hinh);
$slug_id=$this->LuuVideo($link_video,$link_hinh);
if(!$slug_id)
{
echo "loi";exit;
}
$la_video=1;
// continue;// tiep tuc vong lap bo qua cac ham phia sau
}
if($la_video!=1)
{
$elems = $dom->find("img");//tim hinh anh khong phai la video
$link_hinh=preg_replace('/460(\w*)/', "700b", $elems[0]->src);
$slug_id=$this->LuuAnh($link_hinh);
if(!$slug_id)
{
echo "loi";exit;
}
}
echo $link_hinh.'<br>';
$post=new \PostsCollection();
$post->tua_de=$tua_de;
$post->link_hinh="/photo/".$slug_id.'.jpg';
$post->link_goc=$link_hinh;
$post->save();
// $dom->clear();
// unset($dom);
$this->view->pick("LayHinhTuDong/index");
}
It seems that this is your PHP environment problem.
Please set the larger Maximum execution time in php.ini or use the ini_set or set_time_limit.
You can see more details about this.
Thanks
Could you please verify that there is absolutely no problem with destructor on line 140 in simple_html_dom.php? I integrated this library with Laravel and have one usage in total (one new HtmlDomParser()) and I always get stuck at infinite loop of __destruct() calls. I feel like I tried everything and can't get to the bottom of this. Thank you!
Please see this issue for more information.
Update: The issue described only happens when using PHP v7.1.13, version 7.1.14 is having no problems and version 7.1.1 also did not encounter these issues.
I have the same problem with PHP 7.3.7
php -v
PHP 7.3.7 (cli) (built: Jul 3 2019 14:34:10) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans