android - 如何使用维基百科 API 从维基百科页面的特定部分提取数据?
问题描述
我想从维基百科中提取蔬菜/水果的营养部分,并想在我的 android 应用程序中显示它。
这是我到目前为止所得到的..
提取“香蕉”的营养部分
https://en.wikipedia.org/w/api.php?action=parse&page=banana&prop=wikitext§ion=23&format=json
但我不知道如何从我从上面的链接获得的数据中过滤掉这个表(上图右侧的表)。解析这些数据时我必须在我的代码中弄清楚还是我必须对 url 做一些事情?
谁能帮我做到这一点?
解决方案
Yeah, you'll have to do that yourself. You can use https://en.wikipedia.org/api/rest_v1/page/mobile-sections/Banana which is a little easier to use (OTOH it's more internally focused and so less stable) and does remove certain parts of the HTML, but you'd still have to deal with the table. Or you can try https://en.wikipedia.org/api/rest_v1/page/html/Banana which uses the next-generation HTML renderer and has more metadata in the HTML so it's maybe easier to transform, but you'd still have to do the transformation yourself.
推荐阅读
- c# - 使用委托、静态方法和多播将函数作为参数传递
- python - 来自 dynamo 的 Python 解析查询 - TypeError:列表索引必须是整数或切片,而不是 str
- php - 从 WooCommerce 中的类别价格后缀更改中排除特定产品 ID
- flutter - 如何在地图上用颜色发现不同的位置?
- c# - C# 中的非英语复数形式
- angular - SSL证书的角度问题
- flutter - Flutter - DropdownButton onChanged 返回 null
- python - 如何加快代码从字典列表中获取数据
- sql-server - 如何将 OPTION (MAXRECURSION 0) 与 cte insert 一起使用到临时表中
- node.js - 构建单水疗根节点应用程序时未创建 Dist 文件夹