php obtiene la información del encabezado de la página web y la visualización del código fuente de la página web
/**
* compatible; MSIE 6.0 Windows NT 5.1; p>
var $_url,$_method,$_timeout;
var $_scheme,$_host,$_port,$_path,$_query,$_referer;
var $ _header;
var $_response;
/**
* Compatible con el modo PHP5
*
* @param Igual que los siguientes parámetros
*/
función __construct($url=null,$method='GET',$timeout=60){
@set_time_limit(0);
if (!empty($url)) {
$this->connect($url,$method,$timeout); p>
}
return $this;
}
/**
* Objeto de inicialización
*
* @param string $url
* @param string $método
* @param int $timeout
* @return objeto
*/
función Httplib($url=null,$method='GET',$timeout=60){
return $this -> __construct($url,$method,$timeout);
}
/**
* Cambiar la URL de conexión
*
* @param string $url
* @param string $método
* @param int $timeout
* @ devolver objeto
*/
función connect($url=null,$method='GET',$timeout=60){
$this-> _header = null ;
$this->_response = null;
$this->_url = $url;
$this->_method = strtoupper( vacío($ método)? 'GET': $método);
$this->_timeout = vacío($timeout) 30: $tiempo de espera;
if (!empty(? $url) ) {
$this->_parseURL($url);
}
devuelve $this;
}
/**
* Enviar solicitud
*
* @param array $params
* @return bool p>
*/
function send($params=array()) {
$header = null; $respuesta = null;
if (!empty($params)) { $this->_method = 'POST' }
if (function_exists('fsockopen')) {
$ fp = @fsockopen($this->_host,$this->_port,$errno,$errstr,$this->_timeout);
if (!$fp) { return false; } p>
$_port = ((int)$this->_port!==80) ? ':'.$this->_port : null;
$SendStr = "{ $this- >_method} {$this->_path}{$this->_query} HTTP/1.0\r\n";
$SendStr.= "Host:{$this->_host} {$_port }\r\n";
$SendStr.= "Aceptar: */*\r\n";
$SendStr.= "Referente:{$this ->_referer }\r\n";
$SendStr.= "Agente-usuario: ".$this->_SEND_USER_AGENT."\r\n";
$SendStr .= " Pragma: no-cache\r\n";
$SendStr.= "Cache-Control: no-cache\r\n";
//Si es el método POST, Analizar parámetros
if ($this->_method=='POST') {
//Determina si el parámetro es una matriz y genera un bucle en la cadena de consulta
if (is_array($params)) {
$QueryStr = ');
$http->send();
$cuerpo = $http- >respuesta();
echo $cuerpo;