I'm trying to parse some int s from a webpage and I have run into some problems:
1 The webpage is generated using javascript.
This sample code (Credz to Oracle.com. StackOverflow will not let me link) prints out the html code before the javascript is executed.
import java.net.*;
import java.io.*;
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL oracle = new URL("http://www.oracle.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
Q: How can I get the generated html?
2 The webpage is not rendered rendered correctly when going directly to the link: This direct link will render as an empty "shell". Going to this link and clicking Vis utskriftsside (Down to the left) will open a new correctly rendered window.
Q: What is the difference between the two links and how can I access the correctly rendered webpage using the direct link?
EDIT
This is the HTML/JavaScript generating the numbers I'm trying to scrape:
<div id="drawNumbers" class="drawn-numbers">
<script type="text/javascript">
var tableData ='';
if (opener.draw_numbers) {
for(var i = 0; i<opener.draw_numbers.length;i++){
tableData += '<div class="number" style="left:'+(i*28+8)+'px;">';
tableData += '<img width="23" height="23" alt="" src="/nt-keno/result/images/res_keno_tallramme_print.gif">';
tableData += '</div>';
tableData += '<div class="number" style="left:'+(i*28+9)+'px; top:9px; z-index: 30;">' +opener.draw_numbers[i]+ '</div>';
}
}
document.writeln(tableData);
</script>
</div>
Can I import this array into java?
opener.draw_numbers[i]