gpt4 book ai didi

wikipedia - 是否有一个维基百科 API 仅用于检索内容摘要?

转载 作者:行者123 更新时间:2023-12-03 04:24:16 25 4
gpt4 key购买 nike

我只需要检索维基百科页面的第一段。

内容必须采用 HTML 格式,准备好在我的网站上显示(因此 BBCode维基百科特殊代码!)

最佳答案

有一种方法无需任何 HTML 解析即可获取整个“介绍部分”!类似于 AnthonyS's answer通过附加的 explaintext 参数,您可以获得纯文本的介绍部分文本。

查询

以纯文本形式获取 Stack Overflow 的介绍:

使用页面标题:

https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Stack%20Overflow

或者使用pageids:

https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&pageids=21721040

JSON 响应

(警告已删除)

{
"query": {
"pages": {
"21721040": {
"pageid": 21721040,
"ns": 0,
"title": "Stack Overflow",
"extract": "Stack Overflow is a privately held website, the flagship site of the Stack Exchange Network, created in 2008 by Jeff Atwood and Joel Spolsky, as a more open alternative to earlier Q&A sites such as Experts Exchange. The name for the website was chosen by voting in April 2008 by readers of Coding Horror, Atwood's popular programming blog.\nIt features questions and answers on a wide range of topics in computer programming. The website serves as a platform for users to ask and answer questions, and, through membership and active participation, to vote questions and answers up or down and edit questions and answers in a fashion similar to a wiki or Digg. Users of Stack Overflow can earn reputation points and \"badges\"; for example, a person is awarded 10 reputation points for receiving an \"up\" vote on an answer given to a question, and can receive badges for their valued contributions, which represents a kind of gamification of the traditional Q&A site or forum. All user-generated content is licensed under a Creative Commons Attribute-ShareAlike license. Questions are closed in order to allow low quality questions to improve. Jeff Atwood stated in 2010 that duplicate questions are not seen as a problem but rather they constitute an advantage if such additional questions drive extra traffic to the site by multiplying relevant keyword hits in search engines.\nAs of April 2014, Stack Overflow has over 2,700,000 registered users and more than 7,100,000 questions. Based on the type of tags assigned to questions, the top eight most discussed topics on the site are: Java, JavaScript, C#, PHP, Android, jQuery, Python and HTML."
}
}
}
}

文档:API: query/prop=extracts

关于wikipedia - 是否有一个维基百科 API 仅用于检索内容摘要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8555320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com