使用 curl 从 wiki 获取搜索完成项
Get search completion terms from wiki using curl
我正在使用 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'
它 returns 空结果,而我可以看到,这个 api 给出了 output 作为,
["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
是否有任何 curl 参数错误?
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
(...)
我正在使用 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'
它 returns 空结果,而我可以看到,这个 api 给出了 output 作为,
["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
是否有任何 curl 参数错误?
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
(...)