curl url返回有线输出

时间:2017-03-05 04:41:28

标签: python php curl

我正在尝试卷曲https://www.chenyutv.com/ceshi/yunapi.php?v=58ae49f50cf2d11b00b4fce1

在终端,它返回:

<?xml version="1.0" encoding="UTF-8"?><xml_player xxx="2017-03-05 12:33:26"><flashvars>{h->{f->http://www.chenyutv.com/ceshi/yunapi.php?v=[$pat]}</flashvars><video><file><![CDATA[http://60.205.15.71/cloudvideo/kservice-route/get.json?timestamp=1488688314&fid=400204000058AE4DDA00010018300000000000-0000-0000-0145-D57400000000.mp4&ns=video.acfun.cn&vid=58ae49f50cf2d11b00b4fce1&customer_id=5859fdaee4b0eaf5dd325b91&sign=ct58bb94ba0cf2491566baf4d8&oip=771245519&sid=448867538455088ad3c71&token=5691&did=780d9eb79b7fdf85b68434127182f844&ev=1&ctype=87&ep=OMpK5RGtKUHkeqthQ%2B40fg1UQyLtXABpM1HaBsEEW1n9hVy1ygJV6FndJZu8DVQ5A6tYHzbS%2BeYMiwIF%2BhzDVUhAdNQESISyQSRVHTpuS92pf4cob9CNE04QHcmbTu2P&skuid=qq387673116]]></file><size>318946771</size><seconds>6192</seconds></video></xml_player>

所以它基本上是一个通用的xml文件。

但是,如果我在php中卷曲或在python中发出请求,我就无法得到任何东西。

你能解释一下吗?

感谢。

我的PHP代码:

$url = "https://www.chenyutv.com/ceshi/yunapi.php?v=58ae49f50cf2d11b00b4fce1&type=mp4";
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $url); 
curl_setopt($curl, CURLOPT_FAILONERROR,1);
// curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
//followlocation cause infinite waiting time.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
$data=curl_exec($curl);
curl_close($curl);
echo $data;

1 个答案:

答案 0 :(得分:0)

您的cURL $url变量末尾有&type=mp4https://www.chenyutv.com/ceshi/yunapi.php?v=58ae49f50cf2d11b00b4fce1 &amp; type = mp4 )。该URL的cURL不会返回任何数据,但会提到您提到的第一个URL的cURL。

$url = "https://www.chenyutv.com/ceshi/yunapi.php?v=58ae49f50cf2d11b00b4fce1"; // without &type=mp4
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $url); 
curl_setopt($curl, CURLOPT_FAILONERROR,1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
$data=curl_exec($curl);
curl_close($curl);
echo $data; // returns the xml content