【问题标题】:How can I simplify search results from whapi (wikihow api)如何简化 whapi (wikihow api) 的搜索结果
【发布时间】:2022-01-15 10:21:28
【问题描述】:

我使用的是非官方的 API,当我使用搜索时,我得到了很长的烦人的代码。这是代码:

wikihowc = input ("What you would like to learn today: ")
earch_results = search((wikihowc), [1])
print(search_results)

这是我从控制台返回的:

[{'title': 'clean Legos', 'article_id': 1951481, 'url': 'https://www.wikihow.com/Clean-LEGOs'}]

【问题讨论】:

  • 这是蟒蛇吗?您使用的是什么 api 库/模块?
  • 你想简化什么?您只需要 URL 还是只需要文章标题?
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: python filtering


【解决方案1】:

我认为这是 Python,您希望过滤结果以获取文章 URL。

如果是这样,您可以通过列表理解来做到这一点:

wikihowc = input ("What you would like to learn today: ")
search_results = search((wikihowc), [1])
simplified_results = [result["url"] for result in search_results]
print(search_results)
print(simplified_results)

【讨论】:

  • 非常感谢!!!
猜你喜欢
  • 1970-01-01
  • 2011-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多