从给定的URL读取html数据

时间:2018-01-05 12:54:00

标签: php

我有以下代码尝试从网址中提取文字。

include_once("html_parser/simple_html_dom.php");
$html=file_get_html("http://82.77.18.164:8080/Iphone/get_puncte.php");

print_r($html);

echo file_get_contents("http://82.77.18.164:8080/Iphone/get_puncte.php");

echo stream_get_contents(fopen('http://82.77.18.164:8080/Iphone/get_puncte.php', "r")); 

如果我在我的浏览器中访问该网址它工作正常,但是当我使用上面的代码访问php文件时,我会收到以下错误。

PHP Warning:  file_get_contents(http://82.77.18.164:8080/Iphone/get_puncte.php): failed to open stream: Connection refused

PHP警告:stream_get_contents()期望参数1为资源,第9行/home/xxxxx/public_html/test.php中给出布尔值

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

有些服务器拒绝使用IP地址而建议使用curl