我想用query
动作搜索维基百科.我正在使用以下网址:
http://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=apple
That works but I want to get into the first result of the search. How can I do that?
注意:当只有一个结果时,url可以正常工作..
我想用query
动作搜索维基百科.我正在使用以下网址:
http://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=apple
That works but I want to get into the first result of the search. How can I do that?
注意:当只有一个结果时,url可以正常工作..
I don't think you can do both in one query.
1.要获得第一个结果,请使用Opensearch API.
https://en.wikipedia.org/w/api.php?action=opensearch&search=zyz&limit=1&namespace=0&format=jsonfm个
https://en.wikipedia.org/w/api.php
?action=opensearch
&search=zyz # search query
&limit=1 # return only the first result
&namespace=0 # search only articles, ignoring Talk, Mediawiki, etc.
&format=json # jsonfm prints the JSON in HTML for debugging.
This will return:
[
"Zyz",
[
"Zyzomys"
],
[
""
],
[
"https://en.wikipedia.org/wiki/Zyzomys"
]
]
2.您现在有了第一个搜索结果的文章名.要获得这篇文章的第一段(或者你所说的描述),请看我的答案:https://stackoverflow.com/a/19781754/908703