我试图使用cURL和PHP来下载here的HTML源代码(因为它出现在浏览器中)。但不是实际的源代码,而是返回(元刷新链接设置为0)。使用cURL下载网站的HTML源代码,但得到不同于预期的文件
<html>
<head><title>Object moved</title></head>
<body>
<h2>Object moved to <a href="https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&checkda=1&ct=44850&rver=6.1.6195.0&wp=MBI&wreply=http:%2F%2Fwww.windowsphone.com%2Fen-US%2Fapps%2Fea39f002-ac30-e011-854c-00237de2db9e&lc=1033&id=268289">here</a>.
</h2>
</body>
</html>
我试图欺骗引用标题为网站,但它似乎我做错了。代码如下。有什么建议么?由于
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.windowsphone.com/en-US/apps/ea39f002-ac30-e011-854c-00237de2db9e');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_REFERER, "http://www.windowsphone.com/en-US/apps/ea39f002-ac30-e011-854c-00237de2db9e");
$html = curl_exec($ch);
curl_close($ch);
我有一种感觉,我回答了这个之前:http://stackoverflow.com/questions/8046907/how-come-i-cant-download-this-webpage-in-python/ – flesk