【发布时间】:2014-04-26 13:58:53
【问题描述】:
当我尝试通过 cURL 调用 YQL 时,出现以下错误。
不支持 HTTP 版本 说明:网络服务器“engine1.yql.vip.bf1.yahoo.com”正在使用不受支持的 HTTP 协议版本。
以下是使用的代码
// URL
$URL = "https://query.yahooapis.com/v1/public/yql?q=select * from html where url=\"http://www.infibeam.com/Books/search?q=9788179917558\" and xpath=\"//span[@class='infiPrice amount price']/text()\"&format=json";
// set url
curl_setopt($ch, CURLOPT_URL, $URL);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
echo $output;
?>
从浏览器调用相同的 URL 可以正常工作
https://query.yahooapis.com/v1/public/yql?q=select * 来自 html 哪里 url="http://www.infibeam.com/Books/search?q=9788179917558" 和 xpath="//span[@class='infiPrice 金额价格']/text()"&format=json
有人可以指出代码中有什么问题吗?
【问题讨论】:
标签: php http curl yql http-protocols