0

当我在抓取一个网站时,我能够在 10000 个内容中达到 4000 个,它会停下来说

PHP 警告:file_get_contents():第 70 行的 /Users...simple_html_dom.php 中的文件名不能为空 PHP 致命错误:在非对象上调用成员函数 find()

在 simple_html_dom.php 的第 70 行

$contents = file_get_contents($url, $use_include_path, $context, $offset);

我想知道如何绕过空文件名并继续完成该过程?

4

2 回答 2

2
$contents = '';
if(!empty($url)) {
    $contents = file_get_contents($url, $use_include_path, $context, $offset);
}
于 2012-01-07T01:21:13.270 回答
1

您可能只需要确保 $url 具有值...

if(!empty($url)) {
    $contents = file_get_contents($url, $use_include_path, $context, $offset);
}
于 2012-01-07T01:21:53.597 回答