【发布时间】:2016-02-27 12:59:33
【问题描述】:
我尝试了http://php.net/manual/en/function.file-get-contents.php的第一个示例
<?php
$homepage = file_get_contents('http://www.scibet.com/');
echo $homepage;
?>
我只知道:
Notice: file_get_contents(): send of 16 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. in C:\xampp\htdocs\scraper\test.php on line 2
Notice: file_get_contents(): send of 22 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. in C:\xampp\htdocs\scraper\test.php on line 2
Notice: file_get_contents(): send of 19 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. in C:\xampp\htdocs\scraper\test.php on line 2
Notice: file_get_contents(): send of 2 bytes failed with errno=10053 An established connection was aborted by the software in your host machine. in C:\xampp\htdocs\scraper\test.php on line 2
Warning: file_get_contents(http://www.scibet.com/): failed to open stream: HTTP request failed! in C:\xampp\htdocs\scraper\test.php on line 2
问题出在哪里?
【问题讨论】:
-
您要阅读整个网站的内容是什么?
-
是的,我需要从外部 url 获取所有内容的方法...
-
尝试使用 stream_get_contents // 仅当站点服务器和 PHP5+ 中允许 fopen 时才有效 $handle = fopen("websiteyouwanttoscrape.com/file.html", "r"); $contents = stream_get_contents($handle); stackoverflow.com/questions/34834038/… 上的示例
标签: php mysql apache web-scraping file-get-contents