note 108881 deleted from function.curl-setopt by cmb

From: Date: Mon, 21 Nov 2016 19:01:04 +0000
Subject: note 108881 deleted from function.curl-setopt by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207277@lists.php.net to get a copy of this message
Note Submitter: coding query ---- Sometimes we want to extract the HTML content of the remote website page, this technique is called as HTML scrapper. This article will discuss on how we can extract the HTML content of the remote webpage. We can achieve HTML scrapper operation in 2 step operation: Call to Remote Web Page and extract the HTML content. Match the HTML tags using Regular Expression. Call to Remote Web Page using PHP: In PHP there are various ways we can call the remote webpage. But here we will be using CURL to achieve our operation. <?php $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); preg_match_all('/<span>[\\/\\(\\)-:<>\\w\\s]+< \\/span>/',$file_contents,$htmlContent); ?>

« previous php.notes (#207277) next »