【发布时间】:2021-02-28 17:07:04
【问题描述】:
我想用 PHP 做一个简单的网络爬虫。我尝试过使用 file_get_contents()。但它不能正常工作。它显示如下错误。
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed. errno=0 in /storage/emulated/legacy/htdocs/search/crawl.php on line 12
Warning: file_get_contents(http://www.wikipedia.com): failed to open stream: php_network_getaddresses: gethostbyname failed. errno=0 in /storage/emulated/legacy/htdocs/search/crawl.php on line 12
Warning: implode(): Invalid arguments passed in /storage/emulated/legacy/htdocs/search/crawl.php on line 38
是什么意思??第 12 行的代码也是
$mainUrl = "http://www.wikipedia.org";
$str = file_get_contents($mainUrl);
第 38 行的代码,
$all_links = implode(",",$sec_url);
那么现在如何解决这个问题??
【问题讨论】:
-
请edit 将
var_dump(ini_get("allow_url_fopen"));的输出包含在您的问题中。
标签: php web-crawler