2013-10-09 45 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/ –