1

I'm parsing html page that uses javascript function call to show data. I need that data, I know how to parse the page to get function body, but the question is how to call that function from my java program to receive the same data function returns when is called on the site?

EDIT: the concrete web page is http://hedonism.co.uk/wines/, function to display wines is called getWines(), I need all wines info.

5
  • can you add your sample of code to the question Commented Mar 28, 2014 at 13:19
  • What does that JavaScript function do exactly? Is it web- or browser-related? Commented Mar 28, 2014 at 13:19
  • @vikeng21 I updated, please take a look at. Commented Mar 28, 2014 at 13:49
  • @kol sorry I don't get the question. What is the difference? Commented Mar 28, 2014 at 13:50
  • (1) If the code is related to the web browser, then you need to simulate the browser in the Java code (for example, with a headless browser, see Ben's answer). (2) If there is no need to simulate the browser, then the JavaScript can be run by the Rhino engine. If the JavaScript uses the web (AJAX), then this is harder, but seems to be possible: javaworld.com/article/2077796/java-se/… Commented Mar 28, 2014 at 14:36

2 Answers 2

2

Just simply running the JavaScript code on that webpage is not going to cut it, you will have to simulate a browser environment to get reliable results. I suggest you take a look at the list in the correct answer to "automation - headless internet browser" for inspiration.

Sign up to request clarification or add additional context in comments.

Comments

0

Looks like you have similar problem

One of the solutions is to use Selenium to record web page interaction scenario and use that scenario from java

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.