Воспользуйтесь сокетами:
| Код | <?php function getUrlContents($url) { $url_parsed = parse_url($url); $host = $url_parsed["host"]; if ($url == '' || $host == '') { return false; } $port = ($url_parsed["port"] == 0 ? 80 : $url_parsed["port"]); $path = (empty($url_parsed["path"]) ? '/' : $url_parsed["path"]); $path.= (!empty($url_parsed["query"]) ? '?'.$url_parsed["query"] : ''); $out = "GET $path HTTP/1.0\r\nHost: $host\r\nConnection: Close\r\n\r\n"; $fp = fsockopen($host, $port, $errno, $errstr, 30); fwrite($fp, $out); $headers = ''; $content = ''; $buf = ''; $isBody = false; while (!feof($fp)) { $buf = fgets($fp, 1024); if ($isBody) { $content .= $buf; } else { $headers .= $buf; } if ($buf == "\r\n" ) { $isBody = true; } } fclose($fp); return array('headers'=>$headers,'body'=>$content); } $s = getUrlContents('http://ru2.php.net/manual-lookup.php?pattern=fsock'); print '<h3>Заголовки:</h3><textarea rows="10" cols="50">'.$s['headers'].'</textarea>'; print '<h3>Тело:</h3><textarea rows="50" cols="50">'.$s['body'].'</textarea>'; ?>
|
|