2011-11-17 2 views
0

외부 웹 페이지의 특정 사업부를 특정 사업부 (iframe 없음)에로드하고 싶습니다. 내 웹 사이트 중. 예를 들어 : 나는 내 자신의 웹 사이트에이 같은 사업부가 있습니다어떻게 내 웹 사이트의 특정 DIV에 외부 웹 페이지의 특정 DIV를로드 할 수 있습니까?

<div id="weather-status"> Weather Status </div> 

나도이 사이트를 가지고 : http://www.timeanddate.com/weather/ 와이 사이트 (HTTP에서 테이블을로드 할 : //www.timeanddate. com/weather /)을 내 div (날씨 상태) 어떻게 할 수 있습니까? 다음 CSS와

+0

'테이블의 무엇 –

+0

테이블'id'는 이런 일 수 있습니다을 id' :'@Arif –

+0

@Arif weather' : 테이블 ID는 매우 중요하지 않다 –

답변

1
<?php 
    $url = "http://www.timeanddate.com/weather/"; 
    $page_all = file_get_contents($url); 

    preg_match('#<table class="border2 lpad wa">(.*)</table>#ms', $page_all, $div_array); 


    echo "<pre>"; 
    print_r($div_array[0]); 
    echo "</pre>"; 
?> 

:

.wa { 
    margin: 0 auto; 
} 

.border2 { 
    background: none repeat scroll 0 0 #D7D6DC; 
} 

.lpad tr td { 
    padding: 0.2em; 
} 
+0

@Meghdad Hadidi 어떤 PHP 버전을 사용합니까? –

+0

PHP 5.3.8을 사용하고 있으며 잘 실행 중입니다. –

+0

'PHP 버전 5.1.4' 온라인 호스트에서이 코드를 테스트 할 것입니다. –

관련 문제