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.
38 ” cURL Extension<br />
Setting M ultiple Options<br />
If you ’re working <strong>with</strong> <strong>PHP</strong> 5.1.3+ you have access <strong>to</strong> the curl_se<strong>to</strong>pt_array function,<br />
which allo ws you <strong>to</strong> pass in an associative array of setting-value pairs <strong>to</strong> set <strong>with</strong> a<br />
single function call. If you ’re working <strong>with</strong> an older version of <strong>PHP</strong>, the function is<br />
relatively easy <strong>to</strong> write.<br />
U sing this function results in not only less and cleaner code, but in the case of<br />
the native C function it also results in fewer function calls and by proxy impro ved<br />
performance.<br />
<br />
H andling H eaders<br />
CURLOPT_HEADER holds a boolean flag that, when set <strong>to</strong> true, will cause headers <strong>to</strong> be<br />
included in the response string returned by curl_exec.<br />
Another option for getting at some of the data included in the response headers,<br />
such as the HTTP response code, is <strong>to</strong> use the curl_getinfo function as sho wn in the<br />
follo wing example. F or more on what other information this function offers, see its<br />
entry in the <strong>PHP</strong> manual.