신문 기사를 긁어오기 입니다.

<?

function get($url){//문서가져옮
        $fp = fopen($url, "r");
       
        while(!feof($fp)){
                $tmp = fgets($fp, 900);
                $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.donga.com/fbin/output?f=total";
$like[] = "$date_Y$date_M$date_D";

$newspaper[] = "연합신문";
$URL[] = "http://www.yonhapnews.co.kr/services/0400000000.html";
$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 "<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++)
?> 

|

댓글 1개

현이천사님 글을 참 많이 보는거 같으네요 ^^
신문사 소스글 잘 보았습니다
그런데 어떻게 적용해야 하는지 궁금하네요

소스를 드림위버에 넣어보아도 반응이 전혀 없어서요 ......
그누보드소스에 넣어야 하는지 ...
아니면 어떻게 적용하는건지좀 알으켜 주세요 ....

그럼수고하세요 ~~~
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
9년 전 조회 476
9년 전 조회 601
9년 전 조회 573
9년 전 조회 757
9년 전 조회 464
9년 전 조회 547
9년 전 조회 503
9년 전 조회 441
9년 전 조회 515
9년 전 조회 396
9년 전 조회 423
9년 전 조회 385
9년 전 조회 430
9년 전 조회 421
9년 전 조회 869
9년 전 조회 385
9년 전 조회 320
9년 전 조회 586
9년 전 조회 393
9년 전 조회 415
9년 전 조회 367
9년 전 조회 344
9년 전 조회 298
9년 전 조회 285
9년 전 조회 339
9년 전 조회 361
9년 전 조회 298
9년 전 조회 243
9년 전 조회 353
9년 전 조회 295
9년 전 조회 321
9년 전 조회 333
9년 전 조회 374
9년 전 조회 264
9년 전 조회 306
9년 전 조회 370
9년 전 조회 291
9년 전 조회 408
9년 전 조회 342
9년 전 조회 275
9년 전 조회 245
9년 전 조회 294
9년 전 조회 239
9년 전 조회 280
9년 전 조회 302
9년 전 조회 242
9년 전 조회 297
9년 전 조회 255
9년 전 조회 369
9년 전 조회 457
10년 전 조회 414
10년 전 조회 364
10년 전 조회 321
10년 전 조회 370
10년 전 조회 312
10년 전 조회 341
10년 전 조회 293
10년 전 조회 263
10년 전 조회 271
10년 전 조회 304
10년 전 조회 362
10년 전 조회 329
10년 전 조회 382
10년 전 조회 305
10년 전 조회 303
10년 전 조회 306
10년 전 조회 338
10년 전 조회 428
10년 전 조회 535
10년 전 조회 317
10년 전 조회 379
10년 전 조회 317
10년 전 조회 226
10년 전 조회 245
10년 전 조회 441
10년 전 조회 295
10년 전 조회 287
10년 전 조회 281
10년 전 조회 424
10년 전 조회 452
10년 전 조회 953
10년 전 조회 337
10년 전 조회 410
10년 전 조회 318
10년 전 조회 662
10년 전 조회 406
10년 전 조회 371
10년 전 조회 405
10년 전 조회 303
10년 전 조회 528
10년 전 조회 434
10년 전 조회 265
10년 전 조회 349
10년 전 조회 505
10년 전 조회 240
10년 전 조회 267
10년 전 조회 296
10년 전 조회 710
10년 전 조회 402
10년 전 조회 403
🐛 버그신고