내가 자꾸 까먹어서 쓰는 개발 이야기/PHP
원격 html 소스 읽어오기
FIL.
2008. 6. 25. 15:47
728x90
$url = "http://macmall.co.kr/oneborn.html";
$info = parse_url($url);
$send = "POST " . $info["path"] . " HTTP/1.1\r\n"
. "Host: " . $info["host"] . "\r\n"
. "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-length: " . strlen($info["query"]) . "\r\n"
. "Connection: close\r\n\r\n" . $info["query"];
$fp = fsockopen($info[host], 80);
fputs($fp, $send);
$start = false;
$retVal = "";
while (!feof ($fp)) {
$tmp = fgets($fp, 1024);
if ($start == true) $retVal .= $tmp;
if ($tmp == "\r\n") $start = true;
}
fclose($fp);
echo($retVal);