기타 [vb.net] HtmlAgilityPack, Jurassic 을 활용한 JavaScript 활용
페이지 정보
본문
Dim web As HtmlWeb = New HtmlWeb()
Dim htmlDoc = web.Load(html)
Dim htmlNodes = htmlDoc.DocumentNode.SelectNodes("//body")
Dim doc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
Dim script = htmlDoc.DocumentNode.Descendants().Where(Function(n) n.Name = "tr/td/a/img").First().InnerText
Dim engine = New Jurassic.ScriptEngine()
Dim result = engine.Evaluate("(function() { " & script & " return src; })()")
Dim json = JSONObject.Stringify(engine, result)
Console.WriteLine(json)
Console.ReadKey()
html = "<html>
// Some HTML
<script>
var spect = [['temper', 'init', []],
['fw\/lib', 'init', [{staticRoot: '//site.com/js/'}]],
[""cap"",""dm"",[{""tackmod"":""profile"",""xMod"":""timed""}]]];
</script>
// More HTML
</html>"
Dim doc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
doc.LoadHtml(html)
Dim script = doc.DocumentNode.Descendants().Where(Function(n) n.Name = "script").First().InnerText
Dim engine = New Jurassic.ScriptEngine()
Dim result = engine.Evaluate("(function() { " & script & " return spect; })()")
Dim json = JSONObject.Stringify(engine, result)
Console.WriteLine(json)
Console.ReadKey()
'// Grab the content of the first script element
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var script = doc.DocumentNode.Descendants()
.Where(n => n.Name == "script")
.First().InnerText;
'// Return the data of spect and stringify it into a proper JSON object
var engine = new Jurassic.ScriptEngine();
var result = engine.Evaluate("(function() { " + script + " return spect; })()");
var json = JSONObject.Stringify(engine, result);
Console.WriteLine(json);
Console.ReadKey();
첨부파일
-
[Example] JavaScript.zip (5.3M)
2회 다운로드 | DATE : 2022-07-13 13:34:29
- 이전글[vb.net] MACAddress, HDD 정보, CPU ID, MACAddress 등... 22.07.19
- 다음글[vb.net] Assembly GUID 가져오기 22.07.09
댓글목록
등록된 댓글이 없습니다.