我以前像这样使用file_get_content
if($html = @DOMDocument::loadHTML(file_get_contents($url))) {.. }
但是切换到curl,因为它更安全,但是我得到了错误
curl_exec() expects parameter 1, sting is given
我的密码
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$html = curl_exec($url);
curl_close($ch);
if($html) {
$xpath = new DOMXPath($html);
..
..
}
您正在执行URL字符串而不是curl句柄
$html = curl_exec($url);
改成
$html = curl_exec($ch);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句