2013-05-30 63 views
-1

我试图用PHP刮掉this页面的内容。刮在PHP中的链接不工作,但在浏览器中链接正常

链接在浏览器中运行,但在使用curlget_file_contents时,booking.com网站会报告该链接无效。我不确定这是否是我的托管公司reg-123的防火墙问题?

任何人都可以帮忙吗?使用

代码如下:

$url='https://secure-admin.booking.com/booking.html?bn=600861417&hotel_id=279299&l ang=en&code=049ae718b3d22164934cf621bece92ad&message_num=1'; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US)'); 

$result = curl_exec($ch); 
echo $result; 
+4

你应该在booking.com问管理员,如果他们是与你没关系刮他们的网站。也许他们故意阻止这样的请求。 –

+0

你一定要将http://www.php.net/curl_getinfo添加到你的代码中来查看请求和响应的详细信息,以便能够调试这个 –

回答

1

这不是get_file_contents,但file_get_contents: 它只是返回的内容完美!我尝试过这个。此外,我注意到,在您的网址有一个多余空白区域,刚过279299279299&l ang

<?php 
$contents = file_get_contents("https://secure-admin.booking.com/booking.html?bn=600861417&hotel_id=279299&lang=en&code=049ae718b3d22164934cf621bece92ad&message_num=1"); 

echo $contents; 
?> 
+0

啊 - 太简单了!非常感谢你,这可能需要我花几个小时才能找到。 – Paul

相关问题