note 10692 deleted from function.curl-setopt by cmb

From: Date: Sun, 17 Nov 2019 08:59:55 +0000
Subject: note 10692 deleted from function.curl-setopt by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213105@lists.php.net to get a copy of this message
Note Submitter: dan dot polansky at seznam dot cz ---- I used to download www pages to my script and one of the pages was different in MS explorer and different, when I downloaded it. Namely, information, I was really interested in was missing. That was because the server on the other bank of the river was looking at who is downloading the page. Everything got fixed when I pretended I was MSIE. It is done with curl. Here is a function, that you may use in similar situation <?php function download_pretending($url,$user_agent) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch); curl_close ($ch); return $result; } ?>

« previous php.notes (#213105) next »