PHP 웹 소스 긁어오기
페이지 정보
작성자 IN-BEST 댓글 0건 조회 12,646회 작성일 12-09-25 02:41본문
[code]
본문
function open_url($url)
{
if (preg_match('/^(https?)\:\/\/([^\/]+)(.*)/', $url, $pregs))
{
$host = $pregs[2];
$port = ($pregs[1] == 'http' ? 80 : 443);
$suburl = $pregs[3];
if (!$suburl) $suburl = '/';
if ($fp = fsockopen($host, $port, $errno, $errstr, 10))
{
fputs($fp, "GET {$suburl} HTTP/1.0\r\n");
fputs($fp, "Host: {$host}\r\n");
fputs($fp, "User-Agnet: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)\r\n");
fputs($fp, "\r\n");
while (!feof($fp))
{
// $temp .= iconv('UTF-8', 'CP949', fgets($fp, 512)); // UTF-8
$temp .= fgets($fp, 512);
}
fclose($fp);
$arr = explode("\r\n\r\n", $temp, 2);
if (count($arr) < 2) return;
return array(
'header'=>$arr[0],
'body'=>$arr[1]
);
}
}
}
print_r(open_url('http://sir.co.kr/'));
?>[/code]
댓글목록
등록된 댓글이 없습니다.







