회원로그인
16년 전
웹이라는것은 100%오픈되어 있기 때문에 보안설정을 조금만 우회하시면html 소스를 받아올 수 있습니다.지금 싸이월드에 보안설정된것은 HTTP 통신시에 Header값으로 User-Agent속성을 요구하는것 같습니다.보통 file()함수를 사용하면 Header값을 전달 할 수가 없습니다.socket함수를 사용하시면 구현가능합니다.아래에 간단한 예제소를 올려봅니다.
<?php
echo "<base href='http://minihp.cyworld.nate.com/pims/main'>" ;
echo get_url_title("http://minihp.cyworld.nate.com/pims/main/pims_main4.asp?tid=20957128" );
function get_url_title($url, $timeout = 2)
{
$url = parse_url($url);
if (!in_array($url['scheme' ],array('' ,'http' )))
return ;
$fp = fsockopen ($url['host' ], ($url['port' ] > 0 ? $url['port' ] : 80), $errno, $errstr, $timeout);
if (!$fp)
{
return ;
// echo "$errstr ($errno)<br>\n";
}
else
{
fputs ($fp, "GET /" .$url['path' ].($url['query' ] ? '?' .$url['query' ] : '' )." HTTP/1.0\r\nHost: " .$url['host' ]."\r\n" );
fputs($fp ,"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5\r\n\r\n" );
$d = '' ;
$f=0;
$p="" ;
$c="" ;
while (!feof($fp))
{
$c= fgets ($fp,2048);
if ($f==0 && $p=="\r\n" && $c=="\r\n" )
$f=1;
if ($f==0) {
$p=$c;
continue;
}
$d .= $c;
}
fclose ($fp);
return $d;
}
}
?>
추천 : 363
추천
목록