嗨,我必须使一个应用程序与以下要求:
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也不能像预期的那样工作。
我该如何处理这个问题?任何建议都会有所帮助。
发布于 2018-08-15 15:55:50
我在您的查询中注意到两件事。首先,exintro意味着你只能从第一个标题上面得到句子。只有少数文章在此之前有十句话。其次,您将从所有名称空间中获得结果。通过使用grnnamespace=0,您将只能获取文章。所以像这样的东西可能会对你有用:
https://stackoverflow.com/questions/51854619
复制相似问题