require("./simple_html_dom.php");
require("../Snoopy.class.php");
$url = "http://news.naver.com/main/list.nhn?mode=LS2D&mid=sec&sid1=107&sid2=781";
$url = $url."&date=".$_GET['date']
."&page=".$_GET['page'];
$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;
*/
$html = new simple_html_dom();
$html->load($content);
//$html = iconv('euc-kr', 'utf-8', $html); // 한글이 깨질 때 사용
//echo $html;
$i = 0;
$j=0;
$k =0;
$count = 0;
$count1=0;
$count2=0;
$realUrl[20];
$realName[20];
$realSpan[20];
$realSpanW[20];
$page;
$page_day;
$realList = $html->find('.type06_headline li');
$realList1 = $html->find('.type06 li');
$realList2 = $html->find('.paging ');
$realList3 = $html->find('.pagenavi_day ');
foreach($realList as $item)
{
if($item->find('.photo'))
{
$realUrl[$count] = $item->find(' a',1)->href;
$realName[$count] = $item->find(' a',1)->plaintext;
$realSpanW[$count] = $item->find('.writing ',0)->plaintext;
$realSpan[$count++] = $item->find('.date ',0)->plaintext;
} else {
$realUrl[$count] = $item->find(' a',0)->href;
$realName[$count] = $item->find(' a',0)->plaintext;
$realSpanW[$count] = $item->find('.writing ',0)->plaintext;
$realSpan[$count++] = $item->find('.date ',0)->plaintext;
}
$realName[$count-1] = iconv('euc-kr', 'utf-8', $realName[$count-1]);
$realSpanW[$count-1] = iconv('euc-kr', 'utf-8', $realSpanW[$count-1]);
$realSpan[$count-1] = iconv('euc-kr', 'utf-8', $realSpan[$count-1]);
}
foreach($realList1 as $item)
{
if($item->find('.photo'))
{
$realUrl[$count] = $item->find(' a',1)->href;
$realName[$count] = $item->find(' a',1)->plaintext;
$realSpanW[$count] = $item->find('.writing ',0)->plaintext;
$realSpan[$count++] = $item->find('.date ',0)->plaintext;
} else {
$realUrl[$count] = $item->find(' a',0)->href;
$realName[$count] = $item->find(' a',0)->plaintext;
$realSpanW[$count] = $item->find('.writing ',0)->plaintext;
$realSpan[$count++] = $item->find('.date ',0)->plaintext;
}
$realName[$count-1] = iconv('euc-kr', 'utf-8', $realName[$count-1]);
$realSpanW[$count-1] = iconv('euc-kr', 'utf-8', $realSpanW[$count-1]);
$realSpan[$count-1] = iconv('euc-kr', 'utf-8', $realSpan[$count-1]);
}
foreach($realList2 as $item)
{
$page = $item;
}
foreach($realList3 as $item)
{
$page_day = $item;
}
$page = iconv('euc-kr', 'utf-8', $page);
$retitle = '&title='.$title.'" class=';
$page = str_replace('" class=',$retitle, $page);
$page_day = iconv('euc-kr', 'utf-8', $page_day);
$page_day = str_replace('" class=',$retitle, $page_day);
?>