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

<?

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년 전 조회 640
9년 전 조회 602
9년 전 조회 789
9년 전 조회 506
9년 전 조회 573
9년 전 조회 536
9년 전 조회 475
9년 전 조회 550
9년 전 조회 423
9년 전 조회 456
9년 전 조회 412
9년 전 조회 468
9년 전 조회 457
9년 전 조회 896
9년 전 조회 423
9년 전 조회 353
9년 전 조회 621
9년 전 조회 432
9년 전 조회 444
9년 전 조회 400
9년 전 조회 375
9년 전 조회 334
9년 전 조회 314
9년 전 조회 370
9년 전 조회 391
9년 전 조회 328
9년 전 조회 271
9년 전 조회 384
9년 전 조회 327
9년 전 조회 352
9년 전 조회 371
9년 전 조회 403
9년 전 조회 293
9년 전 조회 334
9년 전 조회 395
9년 전 조회 319
9년 전 조회 436
9년 전 조회 367
9년 전 조회 302
9년 전 조회 276
9년 전 조회 319
9년 전 조회 274
9년 전 조회 306
9년 전 조회 333
9년 전 조회 267
9년 전 조회 326
9년 전 조회 286
9년 전 조회 399
9년 전 조회 482
10년 전 조회 443
10년 전 조회 389
10년 전 조회 345
10년 전 조회 397
10년 전 조회 339
10년 전 조회 362
10년 전 조회 323
10년 전 조회 285
10년 전 조회 296
10년 전 조회 326
10년 전 조회 389
10년 전 조회 358
10년 전 조회 405
10년 전 조회 334
10년 전 조회 325
10년 전 조회 333
10년 전 조회 364
10년 전 조회 455
10년 전 조회 558
10년 전 조회 344
10년 전 조회 398
10년 전 조회 342
10년 전 조회 245
10년 전 조회 269
10년 전 조회 461
10년 전 조회 312
10년 전 조회 308
10년 전 조회 298
10년 전 조회 449
10년 전 조회 469
10년 전 조회 967
10년 전 조회 351
10년 전 조회 426
10년 전 조회 334
10년 전 조회 671
10년 전 조회 414
10년 전 조회 384
10년 전 조회 413
10년 전 조회 313
10년 전 조회 539
10년 전 조회 447
10년 전 조회 277
10년 전 조회 362
10년 전 조회 518
10년 전 조회 249
10년 전 조회 285
10년 전 조회 305
10년 전 조회 724
10년 전 조회 415
10년 전 조회 417
🐛 버그신고