是否有(PHP)Web Scraping框架使用Curl而不是file_get_contents?

mar*_*n87 2 php web-scraping

我正准备尝试使用Simple HTML DOM Framework进行抓取:http://simplehtmldom.sourceforge.net/但出于file_get_contents安全原因,在服务器配置中禁用了.

我现在需要找到一个使用Curl的类似框架 - 任何人都知道什么?

我尝试运行斜杠点示例时得到的错误消息是:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /var/www/vhosts/domain.com/httpdocs/crawlfeed/simple_html_dom.php on line 70

pro*_*son 5

只需用cURL向下拉页面,然后将字符串加载到SimpleHTMLDOM中:

$ch = curl_init('http://theurl.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$htmlStr = curl_exec($ch);
curl_close($ch);

$html = new simple_html_dom();

// Load HTML from a string
$html->load($htmlStr);
Run Code Online (Sandbox Code Playgroud)

  • 这没有任何借口..香港专业教育学院以前从未使用过它......我生儿,我生儿;-) (2认同)