当我抓取一个网站时,我能够将其抓取到 10000 个内容中的 4000 个,它会停下来并说
PHP 警告:file_get_contents():文件名不能为空 /Users...simple_html_dom.php 第 70 行 PHP 致命错误:调用 非对象上的成员函数 find()
在 simple_html_dom.php 的第 70 行
$contents = file_get_contents($url, $use_include_path, $context, $offset);
我想知道如何绕过空文件名并继续完成该过程?
$contents = '';
if(!empty($url)) {
$contents = file_get_contents($url, $use_include_path, $context, $offset);
}
您可能只需要确保 $url 有一个值...
if(!empty($url)) {
$contents = file_get_contents($url, $use_include_path, $context, $offset);
}