简体   繁体   English

如何使用Java发送和读取第三方javascript变量

[英]How to use Java to sent and read a third party javascript variables

I have two javascript files: 我有两个JavaScript文件:

http://www.dublinbikes.ie/design/marseille/javascript/gmaps_common.js http://www.dublinbikes.ie/design/marseille/javascript/gmaps_common.js
http://www.dublinbikes.ie/design/marseille/javascript/gmaps_search_station.js http://www.dublinbikes.ie/design/marseille/javascript/gmaps_search_station.js

Which for http://www.dublinbikes.ie/All-Stations/Station-map# website 适用于http://www.dublinbikes.ie/All-Stations/Station-map#网站

What I want to do is to simulate the search a station status action that on the left hand side by set variable 'value' a station number and pass it to gmaps_common.js for execute, then read the result from gmaps_search_station.js that executed variable called html from LeftBlock(id) function. 我想做的是模拟搜索站状态操作,在左侧通过将变量“值”设置为站号并将其传递给gmaps_common.js进行执行,然后从执行变量的gmaps_search_station.js中读取结果从LeftBlock(id)函数调用html

Because I need run whole process automatically several times, so please suggest me could I use Java to do this and how. 因为我需要多次自动运行整个过程,所以请建议我可以使用Java来做到这一点以及如何做到。

Thank you very much for the help. 非常感谢你的帮助。

You should never try to emulate a JavaScript interpreter just to get js variables out of it - just do the same thing the script would do in your language. 您永远不要试图仅仅为了从中获取js变量而模仿JavaScript解释器-只需执行脚本在您的语言中所做的相同的事情即可。 Java is mighty enough. Java足够强大。

The script just gets a list of stations from http://www.dublinbikes.ie/service/carto , and then queries details from http://www.dublinbikes.ie/service/stationdetails/dublin/ {number} ( example ). 该脚本仅从http://www.dublinbikes.ie/service/carto获取站列表,然后从http://www.dublinbikes.ie/service/stationdetails/dublin/ {number}查询详细信息( 示例 ) 。 Java has lots of HTTP and XML libraries, it will be no problem for you to do that, too. Java有许多HTTP和XML库,您也可以做到这一点。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM