require("./simple_html_dom.php");
require("../Snoopy.class.php");
//$url = "https://sports.news.naver.com/schedule/index.nhn";
$url = "https://sports.news.naver.com/kbaseball/index.nhn?category=kbo";
//$url = 'https://sports.news.naver.com/kbaseball/index.nhn';
//$url ='https://sports.news.naver.com/sports/index.nhn?category=baseball';
//;/kbaseball/index.nhn;/kbaseball/issue/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://naver.com/";
$snoopy->fetch($url);
$content = $snoopy->results;
//$content = iconv('euc-kr', 'utf-8', $content); //한글이 깨질 때 사용
$html = new simple_html_dom();
$html->load($content);
//echo $html;
$list= $html->find('.hmb_list .hmb_list_items ');
foreach($list as $item)
{
echo '';
echo '';
break;
}
$team1 = $item->find('.vs_list ',0)->plaintext.'
';
$team2 = $item->find('.vs_list2 ',0)->plaintext.'
';
$href1 = explode(' ', $team1);
$href2 = explode(' ', $team2);
$tv = $item->find('.btn_wrap a',1)->href;
if(count($href1) >27)
{
echo ''.$href1[13].' '.$href1[7].' : '.$href2[7].' '.$href2[13].'';
echo $href1[13].' '.$href1[24].'
';
echo $href2[13].' '.$href2[24].'
';
} else
{
echo ''.$href1[4].' VS '.$href2[4].'';
echo $href1[4].' '.$href1[19].'
';
echo $href2[4].' '.$href2[19].'
';
}
echo $item->find(' em',0)->plaintext.'
';
if(strstr($tv,"/tv/"))
{
$tv = str_replace(
"javascript:popUp('/tv/",
"https://sports.news.naver.com/tv/",$tv);
if (strpos($tv,"'")){
$tv = substr($tv,0,strpos($tv,"'"));
}else{
$tv = "없음";
}
}
if(strstr($tv,"gameVideo")) {
echo '경기영상';
} else {
if($tv)
echo 'TV중계';
else
echo 'tv중계
';
}
echo '';
}
/*
$i--;
$list = $html->find('.selected tr');
foreach($list as $item)
{
$date = $item->find('.td_date ',0)->plaintext;
echo $date.'
';
echo '';
break;
}
$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 '';
}
*/
?>