In the html page there is a javascript like the below and i want to extract the values of the var number.
<script type="text/javascript">
var number= 4443;
</script>
I am using jsoup to parse an html page using this command.
org.jsoup.nodes.Document doc3 = Jsoup.connect("http://htmlpage.com").get();
How can i do it ? Thank you all in advance.
Jsoup is a HTML parser, not a JS parser. Best what you could get with Jsoup is getting the HTML
<script>element(s).Its contents has then to be extracted as text by
Element#text()and parsed further by a different library which is capable of parsing JS code, such as Mozilla Rhino. You could of course also perform trivialStringparsing usingindexOf(),substring(), etc methods or perhaps even using some good regex.