• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting content from a two phase load aspx page

 
Enrico Paolo Lelli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to retrieve data from a aspx page which first load a page with no value in the fields and after a few moments it actually loads the fields' values.
An example is this page: http://clan.z8games.com/charstat_cf.aspx?usn=9013685
I try to load the page in a canonic way with java but I get the page loaded without values

E.g.
<tr>
<td align="left" valign="top" class="stylenav13">Exp.</td>
<td align="left" valign="top" id="td_exp"></td>
</tr>

while if I save the page from the browser after loading is completed, for the same fragment I get

<tr>
<td align="left" valign="top" class="stylenav13">Exp.</td>
<td align="left" valign="top" id="td_exp">5689014</td>
</tr>

The code I used for retrieving the html data is the simple piece of code below:

public String getHTML() {
URL url;
HttpURLConnection conn;
BufferedReader rd;
String line;
String result = "";
try {
url = new URL(urlToRead);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = rd.readLine()) != null) {
result += line;
}
rd.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}

Can please anyone explain me how to get the page with the loaded value using Java? ( I know I could do it via Selenium but I need it with plain old Java )

Thanks,
Enrico.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like much of the page is constructed by Javascript after it's initially loaded. So if you want to reproduce the final version, you're going to need something which can interpret Javascript in the same way as a browser would. That's a non-trivial piece of work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic