简体   繁体   English

PHP Curl没有执行

[英]PHP Curl not executing

I am trying to retrieve the HTML from a user profile on Instagram using cURL. 我试图使用cURL从Instagram上的用户配置文件中检索HTML。

I am new to cURL so do not know the cause of this error. 我是cURL的新手,所以不知道这个错误的原因。

Nothing happens when the cURL is executed , the page seems to refresh? 执行cURL时没有任何反应,页面似乎刷新了?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.instagram.com/zohebchaudhry1/'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiess.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiess.txt');
curl_setopt($ch ,CURLOPT_TIMEOUT , 10);
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" );
$html = curl_exec($ch);
curl_close($ch);
echo $html;

above is the PHP cURL code. 上面是PHP cURL代码。

It appears that cURL is working, however you're unable to see the output because printing HTML may not be desired. 似乎cURL正在工作,但是您无法看到输出,因为可能不需要打印HTML。

I suggest replacing echo $html; 我建议替换echo $html; with echo htmlentities($html); with echo htmlentities($html);

Read more: php.net/htmlentities 阅读更多: php.net/htmlentities

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM