Getting javascript variable value with HTML Agility pack

html html-agility-pack javascript variables

Question

Is it possible to get a javascript variable value with html agility pack?

<script type="text/javascript"> 
var title = "Site title";
var articlesummary = "article summary.";
</script>

Is there any way that html agility pack would allow me to get the value of the variable title for example?

Accepted Answer

You can't get the value of a javascript variable in HTML Agility Pack. You have to use regex.


Popular Answer

Actually you can do it. HtmlAgilityPack gives you the inner html and you pick your texts&variables by your own way.

For example:

htmlDocument.SelectNodes("//script[@language='javascript']");

This code will give you the inner text of script tag. After that, you may split the whole text ending with ";".



Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow