user2879704
user2879704

Reputation:

Get search completion terms from wiki using curl

I am using the wikipedia rest api to find completions for a search term.

Their rest api as document here, shows the example,

Find pages beginning with Te.
    api.php?action=opensearch&search=Te

In curl command, i am using,

curl -H "accept:application/json" -X GET 'http://en.wikipedia.org/w/api.php?action=opensearch&search=Te'

It returns empty result, whereas i can see, this api gives a 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

Is any of the curl parameters wrong?

Upvotes: 1

Views: 773

Answers (1)

Tgr
Tgr

Reputation: 28160

Curl does not automatically follow redirects. Use curl -v to diagnose problems.

$ 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
(...)

Upvotes: 1

Related Questions