使用URL时YQL请求不起作用

时间:2012-04-12 14:23:34

标签: yql yahoo-api

有人能告诉我这个YQL请求有什么问题:

http://query.yahooapis.com/v1/public/yql?&format=json&q=select%20*%20from%20html%20where%20url=%22http%3A%2F%2Fsearch-movies-jc4u2tqsvf5jgd7xxmceezlu24.us-east-1.cloudsearch.amazonaws.com%2F2011-02-01%2Fsearch%3Ffacet%3Dgenre%26return-fields%3Dactor%2Cdirector%2Ctitle%2Cyear%2Ctext_relevance%26q%3DLove%26bq%3D%28and%20%28field%20genre%20'Romance'%29%29%22%20and%20xpath=%22*%22

当我提交它直接抱怨的URL时,它工作正常。我相信我正在适当地逃避所有保留的角色:(

提前致谢!

1 个答案:

答案 0 :(得分:2)

您需要在发出YQL请求之前对bq参数中的空格进行url编码。 YQL select语句为:

select * from html where url="http://search-movies-jc4u2tqsvf5jgd7xxmceezlu24.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?facet=genre&return-fields=actor,director,title,year,text_relevance&q=Love&bq=(and%20(field%20genre%20'Romance'))" and xpath="*"

注意bq URL参数中白色间距的编码。 YQL请求将是:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fsearch-movies-jc4u2tqsvf5jgd7xxmceezlu24.us-east-1.cloudsearch.amazonaws.com%2F2011-02-01%2Fsearch%3Ffacet%3Dgenre%26return-fields%3Dactor%2Cdirector%2Ctitle%2Cyear%2Ctext_relevance%26q%3DLove%26bq%3D(and%2520(field%2520genre%2520'Romance'))%22%20and%20xpath%3D%22*%22&diagnostics=true