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

<?

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년 전 조회 526
9년 전 조회 652
9년 전 조회 619
9년 전 조회 808
9년 전 조회 515
9년 전 조회 595
9년 전 조회 551
9년 전 조회 490
9년 전 조회 567
9년 전 조회 439
9년 전 조회 472
9년 전 조회 428
9년 전 조회 490
9년 전 조회 476
9년 전 조회 911
9년 전 조회 439
9년 전 조회 364
9년 전 조회 632
9년 전 조회 451
9년 전 조회 459
9년 전 조회 416
9년 전 조회 387
9년 전 조회 346
9년 전 조회 327
9년 전 조회 377
9년 전 조회 400
9년 전 조회 342
9년 전 조회 285
9년 전 조회 395
9년 전 조회 338
9년 전 조회 360
9년 전 조회 386
9년 전 조회 421
9년 전 조회 302
9년 전 조회 349
9년 전 조회 407
9년 전 조회 335
9년 전 조회 451
9년 전 조회 383
9년 전 조회 316
9년 전 조회 287
9년 전 조회 340
9년 전 조회 287
9년 전 조회 323
9년 전 조회 348
9년 전 조회 280
9년 전 조회 340
9년 전 조회 301
9년 전 조회 408
9년 전 조회 497
10년 전 조회 455
10년 전 조회 402
10년 전 조회 358
10년 전 조회 413
10년 전 조회 354
10년 전 조회 378
10년 전 조회 333
10년 전 조회 299
10년 전 조회 302
10년 전 조회 334
10년 전 조회 408
10년 전 조회 368
10년 전 조회 420
10년 전 조회 352
10년 전 조회 343
10년 전 조회 351
10년 전 조회 389
10년 전 조회 472
10년 전 조회 572
10년 전 조회 359
10년 전 조회 412
10년 전 조회 355
10년 전 조회 266
10년 전 조회 282
10년 전 조회 470
10년 전 조회 331
10년 전 조회 323
10년 전 조회 315
10년 전 조회 470
10년 전 조회 483
10년 전 조회 988
10년 전 조회 371
10년 전 조회 443
10년 전 조회 350
10년 전 조회 693
10년 전 조회 427
10년 전 조회 403
10년 전 조회 425
10년 전 조회 331
10년 전 조회 558
10년 전 조회 465
10년 전 조회 294
10년 전 조회 381
10년 전 조회 534
10년 전 조회 261
10년 전 조회 300
10년 전 조회 320
10년 전 조회 741
10년 전 조회 431
10년 전 조회 437
🐛 버그신고