如何使用 Google Dictionary 作为 API? [英] How to use to Google Dictionary as an API?

查看:19
本文介绍了如何使用 Google Dictionary 作为 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为 Google Dictionary API 已被弃用(例如,以下)

Because the Google Dictionary API is deprecated (e.g., following)

http://www.google.com/dictionary/json?callback=a&sl=en&tl=en&q=love

并已替换为定义(例如,跟随)

and has been replaced with define (e.g., following)

https://www.google.com/#q=define+love

有谁知道如何在 Java 中使用/调用Google 定义"API?

Does anybody know how to use/invoke the "Google define" API in java?

这是做类似事情的 chrome 扩展.

Here is the chrome extension which does similar thing.

https://chrome.google.com/webstore/detail/google-dictionary-by-goog/mgijmajocgfcbeboacabfgobmjgjcoja

作为替代方案,是否有任何开源字典 API?我发现 Oxford (OED)、Cambridge、Merriam-Webster、Wordnik APIs 在订阅模型中提供 APIs.

As an alternative, are there any open source dictionary APIs? I found Oxford (OED), Cambridge, Merriam-Webster, Wordnik APIs which provide APIs in subscription models.

还发现 Wordnet 3.1 已经很老了.不知道有没有更新.

Also found Wordnet 3.1 which is pretty old. Not sure if it being updated or not.

推荐答案

不幸的是,正如其他人所说,Google Dictionary API 已弃用.

Unfortunately, like others have said, the Google Dictionary API is deprecated.

因为我的项目需要一个 Google Dictionary API,所以我决定创建一个.

As I needed a Google Dictionary API for my project, I decided to create one.

我抓取了网址 https://www.google.com/#q=define+term 的网页,其中 term 是您想要获取的任何单词的含义,并创建了 API.您可以在此处找到它.

I scraped the web page for the URL https://www.google.com/#q=define+term where term is any word you want to get meaning of, and created the API. You can find it here.

向 API 发出 URL 请求的基本语法如下所示:

The basic syntax of a URL request to the API is shown below:

https://api.dictionaryapi.dev/api/v2/entries/<--language_code-->/<--word-->

https://api.dictionaryapi.dev/api/v2/entries/<--language_code-->/<--word-->

例如,要获取英文单词 hello 的定义,您可以发送请求到:

As an example, to get definition of English word hello, you can send request to:

https://api.dictionaryapi.dev/api/v2/entries/zh/你好

API 还提供了该词的其他含义、例句和同义词(如果有).

The API also provides other meanings of the word, example sentences, and synonyms, if any.

如果您希望我包含任何其他详细信息,请发表评论,我很乐意扩展 API 以满足您的需求.

If you want me to include any other details, please comment and I will happily extend the API to cover your needs.

源代码位于 GitHub.

这篇关于如何使用 Google Dictionary 作为 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆