Downloading Files with PHP's Built-in Functions
Before you can appreciate PHP/CURL, you'll need to familiarize yourself with PHP's built-in functions for downloading files from the Internet.
Downloading Files with fopen() and fgets()
PHP includes two simple built-in functions for downloading files from a network—fopen()
and fgets()
. The fopen()
function does two things. First, it creates a network socket, which represents the link between your webbot and the network resource you want to retrieve. Second, it implements the HTTP protocol, which defines how data is transferred. With those tasks completed, fgets()
leverages the networking ability of your computer's operating system to pull the file from the Internet.
Creating Your First Webbot Script ...
Get Webbots, Spiders, and Screen Scrapers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.