php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 5<br />
pecl_http P ECL Extension<br />
The pecl_http extension became available in <strong>PHP</strong> 5 and gained a class for HTTP responses<br />
in <strong>PHP</strong> 5.1. Like the cURL extension, it also wraps the libcurl library and<br />
has similar advantages as a result, such as its internal DNS cache. While the cURL<br />
extension uses resources and configuration options <strong>to</strong> more closely mimic libcurl’s<br />
o wn API, the pecl_http extension offers the same features in the form of procedural<br />
and object-oriented APIs. As a result, code that uses pecl_http is generally shorter<br />
than equivalent code using the cURL extension.<br />
Another major difference is that the cURL extension is considered <strong>to</strong> be part of the<br />
<strong>PHP</strong> core, which means that it is more likely <strong>to</strong> be present in most environments<br />
supporting <strong>PHP</strong>. In contrast, pecl_http must be installed via the pecl installer or<br />
compiled manually from source. In either case, the extension requires the <strong>PHP</strong> and<br />
libcurl development headers <strong>to</strong> be present in order <strong>to</strong> compile properly. N ot technically<br />
being part of the <strong>PHP</strong> core, it is less likely <strong>to</strong> be present or available in shared<br />
hosting environments depending on the hosting pro vider. This may be a concern for<br />
code that is intended <strong>to</strong> be distributed for use in a variety of environments.<br />
To install pecl_http via the pecl installer, PEAR must be installed (see<br />
http://pear.php.net/manual/en/installation.php). A package for PEAR may also be<br />
available through your OS package manager. Once it is installed, simply issue the<br />
command pecl install pecl_http. To install from source, do wnload the latest version<br />
from http://pecl.php.net/get/pecl_http. N ote that this requires the header<br />
files for the <strong>PHP</strong> version you are using, which are contained in the <strong>PHP</strong> source tar-