【发布时间】:2016-06-24 17:54:07
【问题描述】:
因为我的服务器主机禁用了
file_get_contents()
在 simple_html_dom.php 中,
我换了
file_get_html()
与
function file_get_html_using_CuRL($url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
但是下面的代码
$html = file_get_html_using_CuRL($url);
$arvl2_arr = $html->find('div[class="arvl2"]');
返回错误:
Fatal error: Call to a member function find() on a non-object in
我猜问题是因为 $html 不是对象?
我使用的时候代码有效
$html = file_get_html($url);
有没有办法解决这个问题?
【问题讨论】:
标签: php curl file-get-contents simple-html-dom