开发者

Getting javascript variable value with HTML Agility pack

开发者 https://www.devze.com 2023-01-07 02:23 出处:网络
Is it possible to get a javascript variable value with html agility pack? <script type=\"text/javascript\">

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 agilit开发者_Python百科y pack would allow me to get the value of the variable title for example?


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


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 ";".

0

精彩评论

暂无评论...
验证码 换一张
取 消