aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Getting content from a two phase load aspx page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Getting content from a two phase load aspx page" Watch "Getting content from a two phase load aspx page" New topic
Author

Getting content from a two phase load aspx page

Enrico Paolo Lelli
Greenhorn

Joined: Jul 30, 2013
Posts: 1
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
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting content from a two phase load aspx page