when i use the following code to open a page, extra data is returned plus useless HTML and BODY tags. i want just to see the HTML source of the page, not any extra details. how can i revise it?
<?
class CURL {
var $callback = false;
function setCallback($func_name) {
$this->callback = $func_name;
}
function doRequest($method, $url, $vars) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
if ($this->callback)
{
$callback = $this->callback;
$this->callback = false;
return call_user_func($callback, $data);
} else {
return $data;
}
} else {
return curl_error($ch);
}
}
function get($url) {
return $this->doRequest('GET', $url, 'NULL');
}
function post($url, $vars) {
return $this->doRequest('POST', $url, $vars);
}
}
$curl= new CURL;
echo $content=$curl -> get('http://domain-name');
?
---------- extra and useless data:
HTTP/1.1 200 OK Content-Length: 203426 Content-Type: text/html Content-Location: http://domain-name/Index.html Last-Modified: Mon, 15 Jun 2009 13:03:45 GMT Accept-Ranges: bytes ETag: W/"c6519b7b9edc91:b67" Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Date: Mon, 15 Jun 2009 13:16:30 GMT
thank you.