【问题标题】:curl url returned wired outputcurl url 返回有线输出
【发布时间】:2017-03-05 04:41:28
【问题描述】:

我正在尝试 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 中进行 curl 或在 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;

【问题讨论】:

标签: python php curl


【解决方案1】:

您的 cURL $url 变量末尾有 &amp;type=mp4 (https://www.chenyutv.com/ceshi/yunapi.php?v=58ae49f50cf2d11b00b4fce1&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

【讨论】:

    猜你喜欢
    • 2013-07-17
    • 1970-01-01
    • 2013-10-14
    • 2019-06-17
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多