cURL:仅尝试下载页面 [英] cURL: Just trying to download a page
本文介绍了cURL:仅尝试下载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:
include('./simplehtmldom/simple_html_dom.php');
$url = "http://www.turismovenezia.it/Dove-Alloggiare/1322597142.html";
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$output = curl_exec($ch);
//close connection
curl_close($ch);
但是我没有得到任何输出..我期望页面的代码($ url).
but I'm not getting anything as output..I expected the code of the page ($url).
有什么主意吗?
哈维
推荐答案
从不对远程文件使用file_get_contents,它速度慢,效率低且占用大量CPU.改用Curl或fsocket ... fsocket是两者中的佼佼者.
Never use file_get_contents for a remote file, it is slow, inefficient, CPU intensive. Use Curl or fsocket instead... fsocket being the better of of the two.
这篇关于cURL:仅尝试下载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文