首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android Wikipedia api游戏

android Wikipedia api游戏
EN

Stack Overflow用户
提问于 2018-08-15 15:33:22
回答 1查看 113关注 0票数 0

嗨,我必须使一个应用程序与以下要求:

代码语言:javascript
复制
When the user opens the app, it displays the text from a random Wikipedia page. 
(You’re free to use any logic for grabbing text from a random Wiki 
page(preferably using REST APIs)) The game requires a minimum of 10 lines of 
text on the screen. However, we want to show complete paragraphs of text to 
make it easier to understand the content displayed. Use the least number of 
paragraphs required to cross the 10 sentence limit.

我可以从随机的维基页面获得文本,但很多时候文本少于10个句子,为了确保至少10个句子,我使用了这个url:

http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&generator=random&exsentences=10

但是这个url也不能像预期的那样工作。

我该如何处理这个问题?任何建议都会有所帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-15 15:55:50

我在您的查询中注意到两件事。首先,exintro意味着你只能从第一个标题上面得到句子。只有少数文章在此之前有十句话。其次,您将从所有名称空间中获得结果。通过使用grnnamespace=0,您将只能获取文章。所以像这样的东西可能会对你有用:

https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&generator=random&exsentences=10&grnnamespace=0

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51854619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档