2013-10-09 60 views
1

搜索谷歌,PHP文檔和ofc堆棧溢出,找不到合適的東西,我需要一些代碼的幫助,我需要爲我的函數file_get_html寫一個if聲明,使用Simple HTML DOM Parser如果聲明file_get_html簡單的HTML Dom解析器

我需要用一個簡單的回聲返回喜歡Hello World,如果它只是顯示爲http://sweetvideos.net卻會輸出$element->content因爲我目前的劇本確實爲og:image我給它一些嘗試自己幾個小時,並保持與該返回..

file_get_contents(http://sweetvideos.net): failed to open stream: HTTP request failed! HTTP/1.1 404 NOT FOUND

任何人都可以幫我嗎?

我的代碼:

include('include/simple_html_dom.php'); 
$url = "?video=12c11210"; 
$html = file_get_html('http://sweetvideos.net' . $url); 

if ($html->find('meta[property=og:image]')) { 
    foreach ($html->find('meta[property=og:image]') as $element) { 
    $img[] = $element->attr['content']; 
    } 
} 

回答

0

試試這個,看看它是否適合你?

<?php 

$ch = curl_init("http://www.example.com/"); 
$fp = fopen("example_homepage.txt", "w"); 

curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

curl_exec($ch); 
curl_close($ch); 
fclose($fp); 
?> 
+0

我不熟悉捲曲,但自從我目前的代碼工作,我只需要幫助擴展。 –

+0

可以請你分享一下simple_html_dom.php嗎? –

+0

http://simplehtmldom.sourceforge.net/ –