简体   繁体   English

如何在Java中用Excel实现类似于Web查询的功能?

[英]How can I implement similar to the web query feature in Excel in java?

I'm new here and I hope I'm not asking something which has already been answered. 我是新来的,希望我不要问已经回答的问题。 I have searched everywhere but am yet to discover an adequate answer. 我到处搜索过,但尚未找到适当的答案。

My objective is fairly simple: I want to create a program which will stream the live gold and silver rates from: this website 我的目标非常简单:我想创建一个程序,该程序将流转来自以下网站的实时黄金和白银汇率:

How would I be able to pinpoint the values that I want to download? 如何确定要下载的值? Currently, I have managed to implement this using Microsoft Excel's web query feature wherein I am able to select a table from the webpage. 目前,我已经设法使用Microsoft Excel的网络查询功能来实现此目的,其中我可以从网页中选择一个表格。 However, I want to make it a standalone application. 但是,我想使其成为一个独立的应用程序。

By the way, I need to retrieve the rates to perform a calculation which is then displayed to the user. 顺便说一句,我需要检索比率以执行计算,然后将其显示给用户。

I would greatly appreciate any ideas on how this can be achieved. 我将不胜感激关于如何实现这一目标的任何想法。

I think you need to scrape or parse the data from your website. 我认为您需要从网站上scrapeparse数据。 For that take a look at htmlcleaner , JSoup html parsers. 为此,请看htmlcleanerJSoup html解析器。

You can use XPath with htmlcleaner to pinpoint the data.Here is a nice example Xpath Example . 您可以将XPath与htmlcleaner一起使用来查明数据。这里是一个很好的Xpath Example示例

You can use firefox's firebug extension to get the xpath of an element. 您可以使用firefox的firebug扩展来获取元素的xpath。 But your xpath is going to be very huge, by the look of the website you mentioned. 但是从您提到的网站来看,您的xpath将会非常庞大​​。

Than you have to execute the code at specified interval of your choice. 比起您必须按选择的指定间隔执行代码。

And if there is javascript in play than you have to execute the javascript running behind the page using your java code. 而且,如果正在播放javascript ,则必须使用Java代码执行在页面后面运行的javascript。

Try using Rhino from Mozilla and using its integration libraries or by using the JDK 1.6 ScriptEngine facility. 尝试使用Mozilla中的Rhino并使用其集成库或使用JDK 1.6 ScriptEngine工具。

For ScriptEngine Example take a look here- http://metoojava.wordpress.com/2010/06/20/execute-javascript-from-java/ 对于ScriptEngine实例来看看这里- http://metoojava.wordpress.com/2010/06/20/execute-javascript-from-java/

In, short take a look at html parsers to parse the content of your page. 在其中,简短介绍一下html parsers以解析页面的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从头开始在 Java 中实现功能切换? - How can I implement feature toggle in Java from scratch? 如何在 java web 应用程序的 jsp 中实现 if 语句? - How can i implement an if statement in a jsp in java web app? 我如何在Java中实现与Lombok的注释类似的注释 - How I can implement own annotation in Java similar to Lombok's annotations 如何在 Java 中实现 addFields mongoDB 查询 - How can I implement addFields mongoDB query in Java 如何为桌面应用程序安全地实现“自动登录”功能? - How can I implement a “log in automatically” feature securely for desktop applications? 实现Excel小计功能 - Implement Subtotal feature of Excel 如何实现 OneSignal 推送通知到 java(不是 javascript)后端 web 应用程序 - How can I implement OneSignal push notification to java (not javascript) backend web application 如何使用twitter为我的jsp / java web项目实现登录 - how can i implement login with twitter for my jsp/java web project 如何使用 java8 实现以下功能 - How to implement the below feature using java8 如何在java中实现类似于set::swap的功能? - How to implement similar to set::swap function in java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM