Alchemy API,Java 入门 [英] Alchemy API, getting started with Java

查看:61
本文介绍了Alchemy API,Java 入门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始了一个新项目,该项目需要使用 AlchemyAPI 来分析网站上的信息.我已经开始用 Java 编码并使用 Eclipse,但我相对较新,我真的不知道如何实际使用 API.到目前为止,我已经下载了 Java SDK根据 GitHub 上的说明安装了.现在这就是我被困的地方.我如何实际使用 API?我必须导入一些东西吗?如果是,具体是什么/如何?

I've recently started a new project that requires the use of AlchemyAPI to analyze information on websites. I've started coding in Java and I use Eclipse, but I am relatively new and I am just really lost on how to actually use the API. So far, I've downloaded the Java SDK, and installed it according to what it says on GitHub. Now this is where I am stuck. How do I actually use the API? Do I have to import something? If yes, what/how exactly?

dist"文件夹中有.jar"文件形式的示例,但我只能使用java -jar"来执行它们,因此它们在实际学习如何调用或在我的代码中使用 API.

There are examples in the form of ".jar" files in the "dist" folder but I can only execute them using "java -jar", so they do not seem to be that useful in actually learning how to call or use the API in my code.

对指导我的任何帮助将不胜感激.

Any help to guide me would be greatly appreciated.

谢谢!

推荐答案

很简单

1) 在 Eclipse 中创建一个新的 Java 项目.

1) Create a new Java project in Eclipse.

2) 将src"文件夹(从 AlchemyAPI 下载)的内容复制到Eclipse 项目的源文件夹.

2) Copy the the contents of "src" folder (downloaded from AlchemyAPI) into source folder of Eclipse project.

3) 构建项目.

4) "com.alchemyapi.test" 包有示例测试类.

4) "com.alchemyapi.test" package has sample test classes.

5) 这些类从文本文件中读取密钥.

5) These classes read key from text file.

AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("api_key.txt");

因此,您在电子邮件中从 AlchemyAPI 收到的密钥应写入文本文件并在上述命令中提供完整路径.

So the key which you received from AlchemyAPI in email should be written in a text file and give full path in above command.

6) 代码引用示例 html 文件内容如下

6) Code refers sample html file contents as follows

String htmlDoc = getFileContents("data/example.html");

因此您可以更改.html"或.txt"文件的路径以进行分析.

So you can change the path to your ".html" or ".txt" file to analyze.

运行程序时,请确保您有互联网连接.否则会失败.

While running the program make sure you have internet connectivity. Otherwise it will fail.

这篇关于Alchemy API,Java 入门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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