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

<?

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년 전 조회 505
9년 전 조회 635
9년 전 조회 601
9년 전 조회 781
9년 전 조회 500
9년 전 조회 573
9년 전 조회 531
9년 전 조회 470
9년 전 조회 543
9년 전 조회 420
9년 전 조회 454
9년 전 조회 411
9년 전 조회 463
9년 전 조회 452
9년 전 조회 895
9년 전 조회 416
9년 전 조회 350
9년 전 조회 618
9년 전 조회 426
9년 전 조회 442
9년 전 조회 394
9년 전 조회 373
9년 전 조회 331
9년 전 조회 308
9년 전 조회 366
9년 전 조회 387
9년 전 조회 323
9년 전 조회 268
9년 전 조회 380
9년 전 조회 319
9년 전 조회 350
9년 전 조회 363
9년 전 조회 400
9년 전 조회 292
9년 전 조회 334
9년 전 조회 392
9년 전 조회 313
9년 전 조회 433
9년 전 조회 363
9년 전 조회 298
9년 전 조회 272
9년 전 조회 316
9년 전 조회 269
9년 전 조회 303
9년 전 조회 331
9년 전 조회 264
9년 전 조회 324
9년 전 조회 282
9년 전 조회 396
9년 전 조회 478
10년 전 조회 438
10년 전 조회 385
10년 전 조회 343
10년 전 조회 394
10년 전 조회 337
10년 전 조회 357
10년 전 조회 321
10년 전 조회 282
10년 전 조회 295
10년 전 조회 323
10년 전 조회 385
10년 전 조회 355
10년 전 조회 404
10년 전 조회 332
10년 전 조회 322
10년 전 조회 329
10년 전 조회 359
10년 전 조회 451
10년 전 조회 556
10년 전 조회 341
10년 전 조회 392
10년 전 조회 338
10년 전 조회 242
10년 전 조회 263
10년 전 조회 459
10년 전 조회 306
10년 전 조회 303
10년 전 조회 293
10년 전 조회 442
10년 전 조회 466
10년 전 조회 962
10년 전 조회 347
10년 전 조회 421
10년 전 조회 330
10년 전 조회 668
10년 전 조회 412
10년 전 조회 380
10년 전 조회 412
10년 전 조회 311
10년 전 조회 534
10년 전 조회 442
10년 전 조회 274
10년 전 조회 358
10년 전 조회 512
10년 전 조회 248
10년 전 조회 278
10년 전 조회 302
10년 전 조회 718
10년 전 조회 412
10년 전 조회 413
🐛 버그신고