Redian新闻
>
java and javascript 问题请教,有包子
avatar
java and javascript 问题请教,有包子# Java - 爪哇娇娃
l*0
1
The following code written in JAVA should go to a website and download the
html and parse the contents to find the distance between 2 addresses.
But my problem is , The website uses Javascript to return the value of the
distance which JAVA cannot see it when it downloads the html. It's said I
should call the JAVAscript in my JAVA code which I have no clue.
code:
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.regex.*;

avatar
g*g
2
try htmlunit, they build in a javasript engine so you should be able
to get whatever calculated by js.

【在 l*****0 的大作中提到】
: The following code written in JAVA should go to a website and download the
: html and parse the contents to find the distance between 2 addresses.
: But my problem is , The website uses Javascript to return the value of the
: distance which JAVA cannot see it when it downloads the html. It's said I
: should call the JAVAscript in my JAVA code which I have no clue.
: code:
: import java.lang.*;
: import java.io.*;
: import java.net.*;
: import java.util.*;

avatar
Z*e
3
try a different map provider, especially those providing mobile version of
map website, e.g.
http://m.live.com/search/search.aspx?A=routeview&D=MAP&SA=121+Amelia+St%2c+++Mc+Kees+Rocks%2c+PA+15136-3432&EA=300+Ewing+Rd%2c+++Mc+Kees+Rocks%2c+PA+15136-1886
This page has the distance data in plain text
You should know that, most mapping website use JS in web version or provide
a client app in mobile version for exactly this reason: making it difficult
to "steal" their service, so if you use it somewh

【在 l*****0 的大作中提到】
: The following code written in JAVA should go to a website and download the
: html and parse the contents to find the distance between 2 addresses.
: But my problem is , The website uses Javascript to return the value of the
: distance which JAVA cannot see it when it downloads the html. It's said I
: should call the JAVAscript in my JAVA code which I have no clue.
: code:
: import java.lang.*;
: import java.io.*;
: import java.net.*;
: import java.util.*;

avatar
l*0
4
I haven't tried it. are you sure it allows me to manipulate the javacript
functions used by other websites instead of mine?

【在 g*****g 的大作中提到】
: try htmlunit, they build in a javasript engine so you should be able
: to get whatever calculated by js.

avatar
l*0
5
pure research purpose.
The one you provided looks cool.
For your benefit. one big drawback: when this website doesn't recognize an
address, it would use an address the website thinks the best without asking
your advice. Sometimes the result is very ridiculous.
I tested. The correct one should be 3.72 miles. This website returns 326.1
mi (about 5 hours, 18 minutes with traffic).

provide
difficult
get

【在 Z****e 的大作中提到】
: try a different map provider, especially those providing mobile version of
: map website, e.g.
: http://m.live.com/search/search.aspx?A=routeview&D=MAP&SA=121+Amelia+St%2c+++Mc+Kees+Rocks%2c+PA+15136-3432&EA=300+Ewing+Rd%2c+++Mc+Kees+Rocks%2c+PA+15136-1886
: This page has the distance data in plain text
: You should know that, most mapping website use JS in web version or provide
: a client app in mobile version for exactly this reason: making it difficult
: to "steal" their service, so if you use it somewh

avatar
g*g
6
It allows you to have the page as you see it. Not sure it supports all js,
but at least you can try.

【在 l*****0 的大作中提到】
: I haven't tried it. are you sure it allows me to manipulate the javacript
: functions used by other websites instead of mine?

avatar
Z*e
7
it gives no error indication when address is not found
but with the addresses in your link, it should be possible to accurately
determine the distance, otherwise probably you did not provide address in
the correct format?

asking

【在 l*****0 的大作中提到】
: pure research purpose.
: The one you provided looks cool.
: For your benefit. one big drawback: when this website doesn't recognize an
: address, it would use an address the website thinks the best without asking
: your advice. Sometimes the result is very ridiculous.
: I tested. The correct one should be 3.72 miles. This website returns 326.1
: mi (about 5 hours, 18 minutes with traffic).
:
: provide
: difficult

avatar
l*0
8
thanks all. I'm ready to send out the forum money.
avatar
l*0
9
the money has been sent to zeeGee and goodbug. ...
May I know how to make money here?
avatar
k*r
10
I'm not familiar with map service but I suppose it's better to use their
webservice rather than parsing the page. They may change the page anytime
they want and that will break your site.

【在 l*****0 的大作中提到】
: The following code written in JAVA should go to a website and download the
: html and parse the contents to find the distance between 2 addresses.
: But my problem is , The website uses Javascript to return the value of the
: distance which JAVA cannot see it when it downloads the html. It's said I
: should call the JAVAscript in my JAVA code which I have no clue.
: code:
: import java.lang.*;
: import java.io.*;
: import java.net.*;
: import java.util.*;

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。