我想刮簡單的html dom kickasstorrents,但我得到一個錯誤,我甚至還沒有開始。我跟着一些簡單的HTML教程,我已經設置了我的URL並使用curl。試圖抓住簡單的html dom kickasstorrents
代碼如下:
<?php
require('inc/config.php');
include_once('inc/simple_html_dom.php');
function scrap_kat() {
// initialize curl
$html = 'http://katcr.to/new/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $html);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$ip=rand(0,255).'.'.rand(0,255).'.'.rand(0,255).'.'.rand(0,255);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/".rand(3,5).".".rand(0,3)." (Windows NT ".rand(3,5).".".rand(0,2)."; rv:2.0.1) Gecko/20100101 Firefox/".rand(3,5).".0.1");
$html2 = curl_exec($ch);
if($html2 === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
// create HTML DOM
$kat = file_get_contents($html);
}
curl_close($ch);
// scripting starts
// clean up memory
$kat->clear();
unset($kat);
// return information
return $ret;
}
$ret = scrap_kat();
echo $ret;
?>
我收到錯誤
Fatal error: Call to a member function clear() on resource in C:\wamp64\www\index.php on line 36
我該怎麼辦錯了嗎? 謝謝。
我可以確認那個頁面上的simple-html-d扼流圈。你可以[嘗試作爲替代](https://github.com/monkeysuffrage/advanced_html_dom)。 – pguardiario