note 108881 added to function.curl-setopt
| From: | codingquery | Date: | Thu, 31 May 2012 17:53:01 +0000 |
| Subject: | note 108881 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188349@lists.php.net to get a copy of this message | ||
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, for more information on connecting to
remote web page we can refer to . But here we will be using CURL to achieve our operation.
$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);
For more details readt the full article
http://www.codingquery.com/html-scrapper-in-php-source-code
----
Server IP: 59.162.86.8
Probable Submitter: 59.93.205.30
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/108881
Del: integrated -- https://master.php.net/note/delete/108881/integrated
Del: useless -- https://master.php.net/note/delete/108881/useless
Del: bad code -- https://master.php.net/note/delete/108881/bad+code
Del: spam -- https://master.php.net/note/delete/108881/spam
Del: non-english -- https://master.php.net/note/delete/108881/non-english
Del: in docs -- https://master.php.net/note/delete/108881/in+docs
Del: other reasons-- https://master.php.net/note/delete/108881
Reject -- https://master.php.net/note/reject/108881
Search -- https://master.php.net/manage/user-notes.php