뉴스 소스 .... 정보
기타 뉴스 소스 ....본문
width=660 height=500 border=0 frameborder=0 marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>
예제말고 섹션(?)별로 출력해 보려고 했는데 힘드네요.
추천
0
0
댓글 3개
<?
function get($url){//문서가져옮
$fp = fopen($url, "r");
while(!feof($fp)){
$tmp = fgets($fp, 1024);
$temp .= $tmp;
}
fclose($fp);
return $temp;
}//function get
function Strip($all){// 링크랑 제목만 빼오기
$link_pm=strpos($all,">");
$link=substr($all,0,$link_pm);
if(!$link) return;
if(ereg("\"",$link)){
$link_p=strpos($link,"\"");
$link=substr($link,$link_p+1);
$link_p=strpos($link,"\"");
$link=substr($link,0,$link_p);
}
if(ereg("'",$link)){
$link_p=strpos($link,"'");
$link=substr($link,$link_p+1);
$link_p=strpos($link,"'");
$link=substr($link,0,$link_p);
}
$link=trim($link);
$substr=substr($all,$link_pm+1);
$substr_p=strpos($substr,"</a>");
$substr=substr($substr,0,$substr_p);
$strip=strip_tags($substr);
$strip=trim($strip);
return array(link => $link, sub => $strip);
}//function strip($all)
function makeUrl($Url, $Link){
if(!strpos($Link,"http://") && substr_count("$Link","http://")) return $Link;
$eURL = pathinfo("$Url");
$host = parse_url($Url);
$host = $host[scheme]."://".$host[host];
$Link = "/".$Link; //링크가 루트인지 확인위해 임의로 붙인다.
if(substr_count("$Link","../")){ //한칸앞으로
$Link = str_replace("./../", "", $Link);
$Link = str_replace("../", "", $Link);
$pos = strrpos($eURL["dirname"], "/");
$makeUrl = substr($eURL["dirname"],0,$pos);
$makeUrl = "$makeUrl"."$Link";
}else if(substr_count("$Link","//") && !strpos($Link, "//")){ //루트로 가라
$makeUrl = $host."/".str_replace("//", "", $Link);
}else{ //제자리
$Link = str_replace("./", "", $Link);
$makeUrl = $eURL["dirname"]."$Link";
}
return $makeUrl;
}
////////////////////////////////////// 펑션끝
$date_Y = date("Y");
$date_M = date("m");
$date_D = date("d");
$mdate = "$date_Y.$date_M.$date_D"; //확장성 위해 이르케
////////////////////////////////////////////////////////////<== 신문사별설정 추가가능
$newspaper[] = "조선일보";
$URL[] = "http://www.chosun.com/it/";
$like[] = "$date_Y$date_M$date_D";
$newspaper[] = "중앙일보";
$URL[] = "http://www.joins.com/it/list/it_list.html";
$like[] = "$date_Y$date_M$date_D";
$newspaper[] = "동아일보";
$URL[] = "http://www.donga.com/fbin/output?f=totalk&code=k__";
$like[] = "$date_Y$date_M$date_D";
////////////////////////////////////////////////////////////<== 여그까지 신문사별설정
for($x=0; $x < sizeof($newspaper); $x++){
$temp = get($URL[$x]);
$all = split("href =|HREF =|href=|HREF=",$temp);//--> url 추출
for($i=0; $i < sizeof($all); $i++){
$kisa = Strip($all[$i]);
if(ereg($like[$x], $kisa[link]) && 20 < strlen($kisa[sub])){
$LinkURL = makeUrl($URL[$x], $kisa[link]);
echo "<br><a href='$LinkURL'>[$newspaper[$x]]$kisa[sub]</a><br>";
}//if(ereg($like[$x], $kisa[link]) && 20 < strlen($kisa[sub]))
}//for($i=0; $i < sizeof($all); $i++)
}//for($x=0; $x < sizeof($newspaper); $x++)
?>
소스 입니다. 예제화면은 http://www.slgi.co.kr/bikenews.php 랍니다.
제 경우나 위의 예제화면은 동아일보의 전체기사를 실시간 업데이트 하고
있습니다.
자동차 기사, 오토바이 기사만 두개로 나누어 빼어오려 했는데 이게 잘
안되더라구요. 검색 사이트의 경우는 뭘로 막아 놨는지 처음에만 잠깐
보이다가 감감 무소식 이더군요. 참고삼아 보세요. 그냥 이대로 쓰던가
방법을 더 모색해 보던가 해야죠.^^;
function get($url){//문서가져옮
$fp = fopen($url, "r");
while(!feof($fp)){
$tmp = fgets($fp, 1024);
$temp .= $tmp;
}
fclose($fp);
return $temp;
}//function get
function Strip($all){// 링크랑 제목만 빼오기
$link_pm=strpos($all,">");
$link=substr($all,0,$link_pm);
if(!$link) return;
if(ereg("\"",$link)){
$link_p=strpos($link,"\"");
$link=substr($link,$link_p+1);
$link_p=strpos($link,"\"");
$link=substr($link,0,$link_p);
}
if(ereg("'",$link)){
$link_p=strpos($link,"'");
$link=substr($link,$link_p+1);
$link_p=strpos($link,"'");
$link=substr($link,0,$link_p);
}
$link=trim($link);
$substr=substr($all,$link_pm+1);
$substr_p=strpos($substr,"</a>");
$substr=substr($substr,0,$substr_p);
$strip=strip_tags($substr);
$strip=trim($strip);
return array(link => $link, sub => $strip);
}//function strip($all)
function makeUrl($Url, $Link){
if(!strpos($Link,"http://") && substr_count("$Link","http://")) return $Link;
$eURL = pathinfo("$Url");
$host = parse_url($Url);
$host = $host[scheme]."://".$host[host];
$Link = "/".$Link; //링크가 루트인지 확인위해 임의로 붙인다.
if(substr_count("$Link","../")){ //한칸앞으로
$Link = str_replace("./../", "", $Link);
$Link = str_replace("../", "", $Link);
$pos = strrpos($eURL["dirname"], "/");
$makeUrl = substr($eURL["dirname"],0,$pos);
$makeUrl = "$makeUrl"."$Link";
}else if(substr_count("$Link","//") && !strpos($Link, "//")){ //루트로 가라
$makeUrl = $host."/".str_replace("//", "", $Link);
}else{ //제자리
$Link = str_replace("./", "", $Link);
$makeUrl = $eURL["dirname"]."$Link";
}
return $makeUrl;
}
////////////////////////////////////// 펑션끝
$date_Y = date("Y");
$date_M = date("m");
$date_D = date("d");
$mdate = "$date_Y.$date_M.$date_D"; //확장성 위해 이르케
////////////////////////////////////////////////////////////<== 신문사별설정 추가가능
$newspaper[] = "조선일보";
$URL[] = "http://www.chosun.com/it/";
$like[] = "$date_Y$date_M$date_D";
$newspaper[] = "중앙일보";
$URL[] = "http://www.joins.com/it/list/it_list.html";
$like[] = "$date_Y$date_M$date_D";
$newspaper[] = "동아일보";
$URL[] = "http://www.donga.com/fbin/output?f=totalk&code=k__";
$like[] = "$date_Y$date_M$date_D";
////////////////////////////////////////////////////////////<== 여그까지 신문사별설정
for($x=0; $x < sizeof($newspaper); $x++){
$temp = get($URL[$x]);
$all = split("href =|HREF =|href=|HREF=",$temp);//--> url 추출
for($i=0; $i < sizeof($all); $i++){
$kisa = Strip($all[$i]);
if(ereg($like[$x], $kisa[link]) && 20 < strlen($kisa[sub])){
$LinkURL = makeUrl($URL[$x], $kisa[link]);
echo "<br><a href='$LinkURL'>[$newspaper[$x]]$kisa[sub]</a><br>";
}//if(ereg($like[$x], $kisa[link]) && 20 < strlen($kisa[sub]))
}//for($i=0; $i < sizeof($all); $i++)
}//for($x=0; $x < sizeof($newspaper); $x++)
?>
소스 입니다. 예제화면은 http://www.slgi.co.kr/bikenews.php 랍니다.
제 경우나 위의 예제화면은 동아일보의 전체기사를 실시간 업데이트 하고
있습니다.
자동차 기사, 오토바이 기사만 두개로 나누어 빼어오려 했는데 이게 잘
안되더라구요. 검색 사이트의 경우는 뭘로 막아 놨는지 처음에만 잠깐
보이다가 감감 무소식 이더군요. 참고삼아 보세요. 그냥 이대로 쓰던가
방법을 더 모색해 보던가 해야죠.^^;
소스라고 하고 소스는 없네요 ^^
좋은 정보 ^ 감사합니다.dfs