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 8<br />
R o l l i n g Y Own o u r<br />
First, it should go <strong>with</strong>out saying that it’s generally better <strong>to</strong> use and build upon an<br />
existing library rather than trying <strong>to</strong> roll your o w n from scratch. F o r one thing, you<br />
can get a number of features “ f o rfree” that way <strong>with</strong> no work required on your part.<br />
F o r another, developers outside of your team and projects work on those libraries,<br />
and in the words of Eric S. Raymond, “ G i v e n enough eyes, all bugs are shallow.”<br />
H o w e v e r, it certainly doesn’t hurt <strong>to</strong> be familiar <strong>with</strong> this information even if you<br />
don’t plan <strong>to</strong> build your o w n client. Doing so gives you more capability <strong>to</strong> troubleshoot<br />
issues <strong>with</strong> existing libraries and contribute patches back <strong>to</strong> their project<br />
teams.<br />
Whatever your motivation, here we go.<br />
Sending R e q u e s t s<br />
In addition <strong>to</strong> wrappers for specific pro<strong>to</strong>cols, the streams extension also offers<br />
socket transports for dealing <strong>with</strong> data at a lower level. One of these socket transports<br />
is for TCP, or T r a n s m Control i s s Pro<strong>to</strong>col, i o n which is a core internet pro<strong>to</strong>col<br />
used <strong>to</strong> ensure reliable delivery of an ordered sequence of by t e s. The socket transport<br />
facilitates sending a raw data stream, in this case a manually constructed HTTP<br />
request, <strong>to</strong> a server.<br />