2013-07-22 22 views
0

我正在使用curl來獲取頁面。問題是,我試圖讓我自己的「標題」div底部的捲曲內容。儘管如此,cURL的CSS讓我的格式變得糟糕。如何在不放入iframe的情況下包含cURL'd內容?爲cURL'd內容創建容器

public function curl ($url, $options) 
{ 
    $handle = curl_init($url); 
    curl_setopt_array($handle, $options); 
    ob_start(); 
    $buffer = curl_exec($handle); 
    ob_end_clean(); 
    curl_close($handle); 
    return $buffer; 
} 

回答

0

您可以嘗試僅輸出其正文以避免加載任何其他css文件。

1

你可以試試這個:

$content = curl($url, $options = array()); 

preg_match('/<body>(.*?)</body>/is', $content, $matches); 

if(!empty($matches)) { 

$body = $matches[0]; 

//header with your css 
echo $header; 

//parsed content 
echo $body; 

//footer 
echo $footer; 
} 

注:代碼沒有測試。

希望它有幫助。

+0

+1只要樣式元素不在體內,就應該可以工作......如果它仍然是一個問題,您可以將它們放回去。 – Orangepill