require("./simple_html_dom.php");
require("../Snoopy.class.php");
//$url = "http://sports.news.naver.com/kbaseball/schedule/index.nhn"
$url = 'https://sports.news.naver.com/kbaseball/schedule/index.nhn'
."?month=".$_GET['month']
."&year=".$_GET['year'];
//$url = 'https://sports.news.naver.com/kbaseball/schedule/index.nhn';
//$content = file_get_contents($url);
$snoopy = new snoopy;
$snoopy->agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$snoopy->referer = "http://ya-ho.com/";
$snoopy->fetch($url);
$content = $snoopy->results;
//$content = iconv('euc-kr', 'utf-8', $content); //한글이 깨질 때 사용
$html = new simple_html_dom();
$html->load($content);
//echo $html;
$lyr = $html->find('.lyr_slt a',10)->plaintext;
$list = $html->find('.sch_tb_head ');
echo '';
foreach($list as $item)
{
$y = $item->find(' strong',0);
echo ''.$y.'';
}
$wrap = $html->find('.tb_wrap div');
foreach($wrap as $item)
{
$date = $item->find('.td_date ',0)->plaintext;
if($date)
echo ''.$date.'';
if($item->find('.td_none ',0)->plaintext)
{
echo ''."프로야구 경기가 없습니다.".'';
continue;
}
$list1 = $item->find(' tr');
foreach($list1 as $item)
{
$hour = $item->find('.td_hour ',0)->plaintext;
$teamLft = $item->find('.team_lft ',0)->plaintext;
$score = $item->find('.td_score ',0)->plaintext;
$teamRgt = $item->find('.team_rgt ',0)->plaintext;
$tv = $item->find('.td_btn a',1)->href;
if(strstr($tv,"/tv/"))
{
$tv = str_replace(
"javascript:popUp('/tv/",
"http://sports.news.naver.com/tv/",$tv);
if (strpos($tv,"'")){
$tv = substr($tv,0,strpos($tv,"'"));
}else{
$tv = "없음";
}
}
$stadium = $item->find('.td_stadium ',0)->plaintext;
$stadium1 = $item->find('.td_stadium ',1)->plaintext;
echo ''.$teamLft.' '.$score.' '.$teamRgt.' '.$state[$i].''.'
';
//echo $teamLft.': '.$pitcher1[$i].'
';
//echo $teamRgt.': '.$pitcher2[$i--].'
';
echo $hour.'
';
if(strstr($tv,"gameVideo")) {
echo '경기영상';
} else {
if($tv)
echo 'TV중계';
else
echo 'tv중계
';
}
echo $stadium.'
';
echo $stadium1.'
';
}
}
echo '
';
?>