Browsing around...
News  News Links  Links Blog  Blog Italiano  Español 
Request wepages with cURL

cURL is a package of libraries and softwares which allows to interface with many different communication protocols, such as HTTP. PHP includes the extension libcurl, which, if enabled, allows to use these functionalities. The following PHP code uses libcurl to request a page from a webserver (as if it were a browser), and to store it in a variable. It can be very useful for including some code of a webpage into another page, without the use of iFrames or other similar solutions. The most interesting thing of this solution is surely the fact of getting the pure HTML code, after the sever side codes, like PHP or ASP, have been parsed.

Code of curl_en.php

#This script requests a web page from internet, 
# and stores it in a variable

# Link of the webpage

# cURL code. It requests the webpage and stores it in $data
$ch curl_init() or die(curl_error());
$data=curl_exec($ch) or die(curl_error());

# Print of $data
echo $data;

# Errors
echo curl_error($ch);

Fatal error: Call to undefined function sqlite_open() in /membri/giacobbe85/include/ on line 324