我想从PHP网站解析页面内容。例如,远程网站可能是http://admin.rankedgaming.com。
我尝试了网上提供的所有内容来解决此问题,但我无法获取此特定页面的内容:
http://admin.rankedgaming.com/commands/banhistory/bans.php?m=0&var=ihatepoints
尝试使用file_get_contents
传递Cookie并从我的浏览器复制cURL标头并将其嵌入我的php文件中,没有任何运气。使用cURL或file_get_contents访问时,它将始终显示登录页面。但它通常可以在我的浏览器上运行。什么阻止我访问它?
出于身份验证的目的,虚拟ID传递是:
user = ihatepoints
pass = ihate
提前致谢。
答案 0 :(得分:0)
使用Curl:
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_USERPWD, "ihatepoints:ihate");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($ch);
curl_close($ch);
echo $return;