我正在使用wikipedia rest api查找搜索词的完成情况。
他们的休息api作为文档here,显示了示例,
Find pages beginning with Te.
api.php?action=opensearch&search=Te
在curl命令中,我正在使用
curl -H "accept:application/json" -X GET 'http://en.wikipedia.org/w/api.php?action=opensearch&search=Te'
它返回空结果,而我可以看到,这个api给出output as,
["Te",["Te","Texas A&M University","Texas State Highway 52","Texas Farm to Market Road 60","Tern","TES4","Texas Tech University","Teetotalism","Temple Knights","TED (conference)"],["This is a redirect
是否有任何卷曲参数错误?
答案 0 :(得分:1)
Curl不会自动跟踪重定向。使用curl -v
来诊断问题。
$ curl -vH "accept:application/json" -X GET 'http://en.wikipedia.org/w/api.php?action=opensearch&search=Te'
(...)
< HTTP/1.1 301 TLS Redirect
(...)
< Location: https://en.wikipedia.org/w/api.php?action=opensearch&search=Te
(...)