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

<?

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년 전 조회 507
9년 전 조회 639
9년 전 조회 602
9년 전 조회 789
9년 전 조회 504
9년 전 조회 573
9년 전 조회 535
9년 전 조회 473
9년 전 조회 547
9년 전 조회 423
9년 전 조회 456
9년 전 조회 412
9년 전 조회 468
9년 전 조회 457
9년 전 조회 896
9년 전 조회 420
9년 전 조회 353
9년 전 조회 621
9년 전 조회 430
9년 전 조회 444
9년 전 조회 399
9년 전 조회 374
9년 전 조회 334
9년 전 조회 313
9년 전 조회 369
9년 전 조회 391
9년 전 조회 327
9년 전 조회 271
9년 전 조회 383
9년 전 조회 327
9년 전 조회 351
9년 전 조회 370
9년 전 조회 402
9년 전 조회 293
9년 전 조회 334
9년 전 조회 395
9년 전 조회 316
9년 전 조회 436
9년 전 조회 366
9년 전 조회 301
9년 전 조회 275
9년 전 조회 318
9년 전 조회 274
9년 전 조회 306
9년 전 조회 333
9년 전 조회 267
9년 전 조회 326
9년 전 조회 285
9년 전 조회 398
9년 전 조회 481
10년 전 조회 440
10년 전 조회 389
10년 전 조회 344
10년 전 조회 395
10년 전 조회 338
10년 전 조회 361
10년 전 조회 323
10년 전 조회 284
10년 전 조회 296
10년 전 조회 326
10년 전 조회 388
10년 전 조회 357
10년 전 조회 405
10년 전 조회 333
10년 전 조회 324
10년 전 조회 332
10년 전 조회 362
10년 전 조회 454
10년 전 조회 557
10년 전 조회 343
10년 전 조회 397
10년 전 조회 341
10년 전 조회 244
10년 전 조회 267
10년 전 조회 460
10년 전 조회 310
10년 전 조회 308
10년 전 조회 298
10년 전 조회 447
10년 전 조회 469
10년 전 조회 967
10년 전 조회 351
10년 전 조회 426
10년 전 조회 334
10년 전 조회 670
10년 전 조회 414
10년 전 조회 383
10년 전 조회 413
10년 전 조회 313
10년 전 조회 539
10년 전 조회 446
10년 전 조회 277
10년 전 조회 360
10년 전 조회 517
10년 전 조회 249
10년 전 조회 284
10년 전 조회 305
10년 전 조회 723
10년 전 조회 415
10년 전 조회 417
🐛 버그신고