gpt4 book ai didi

mediawiki - 维基百科 Api 获取单词量

转载 作者:行者123 更新时间:2023-12-02 23:29:23 25 4
gpt4 key购买 nike

我对 Wikipedia api 的所有选项有点困惑。我的目标是获取维基百科页面的字数。我有维基百科的网址。

搜索选项确实返回此值:

http://en.wikipedia.org/w/api.php?format=xml&action=query&list=search&srsearch=camera&srlimit=1

会回来

<api>
<query-continue>
<search sroffset="1"/>
</query-continue>
<query>
<searchinfo totalhits="68658"/>
<search>
<p ns="0" title="Camera" snippet="A <span class='searchmatch'>camera</span> is an optical instrument that records image s that can be stored directly, transmitted to another location, or both. <b>...</b> " size="43246" wordcount="6348" timestamp="2014-04-29T15:48:07Z"/>
</search>
</query>
</api>

(向右滚动一点,您会发现字数统计

但是此查询正在进行搜索并显示 1 个热门结果。但是,当我搜索 URL 中的维基百科名称时,它并不总是找到该记录作为第一个结果。

有没有办法让这个字数统计到维基百科页面?

最佳答案

没有其他 API 提供此信息,因此使用 list=search 进行拼凑是唯一的方法。如果您知道确切的标题,则可以通过将 &srwhat=nearmatch 附加到查询中来获得更好的结果(但它始终会返回 1 个结果)。请参阅the docs并尝试 the sandbox了解更多信息。

请注意,字数统计不会存储在数据库中,因此 API 必须转到 Lucene/Elasticsearch 来获取此信息,但速度并不快,因此如果您需要大量此信息,您应该下载 dump相反。

关于mediawiki - 维基百科 Api 获取单词量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23666554/

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