note 116121 deleted from function.curl-init by sobak

From: Date: Thu, 01 Dec 2016 17:34:47 +0000
Subject: note 116121 deleted from function.curl-init by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207898@lists.php.net to get a copy of this message
Note Submitter: qrworld.net ---- Here you have a function that I use to get the content of a URL using cURL: function getUrlContent($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $data = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return ($httpcode>=200 && $httpcode<300) ? $data : false; } The source comes from this website: http://softontherocks.blogspot.com/2014/11/descargar-el-contenido-de-una-url.html

« previous php.notes (#207898) next »