官方资料:http://phantomjs.org/quick-start.html
从官方下载phantomjs.exe,拷贝它与要执行的js同目录打开cmd,输入命令行(参考官方资料的命令行)
phantomjs XX.js 参数1 参数2获得结果
示例代码:https://github.com/zLulus/NotePractice/tree/dev3/Console/CodeLibrary/ExcuteJsByPhantomjs
1.jint https://github.com/sebastienros/jint可用,但是没有JS的环境https://github.com/sebastienros/jint/issues/240
//引用:Jint string filePath = $"{Environment.CurrentDirectory}//ExcuteJs//TestJs.js"; string data1 = "1"; string data2 = "2"; string jsCode = System.IO.File.ReadAllText(filePath); var square = new Engine() .SetValue("data1", data1) // define a new variable .SetValue("data2", data2) // define a new variable .Execute(jsCode) // execute a statement .GetCompletionValue() // get the latest statement completion value .ToObject(); // converts the value to .NEThttps://github.com/zLulus/NotePractice/tree/dev3/Console/CodeLibrary/ExcuteJs2.Microsoft.JScripthttps://msdn.microsoft.com/zh-cn/library/microsoft.jscript.aspx?f=255&MSPPError=-21472173963.使用CefSharp创造浏览器环境
CefSharp参考我的资料:https://www.cnblogs.com/Lulus/p/7998297.html
(PS:还有几篇关于CefSharp的资料,在此不一一列出)
4.Microsoft.ClearScript(比较新,没有实验) https://github.com/Microsoft/ClearScript
控制台http请求网页->网页调用js->得到结果js对象->结果返回给控制台(即时通讯:SignalR)
即时通讯参考我的资料:http://www.cnblogs.com/Lulus/p/8780595.html
JS翻译成C#……是的,翻译=.=
写完了很开心,结案么么哒(づ ̄ 3 ̄)づ
转载于:https://www.cnblogs.com/Lulus/p/8780599.html
相关资源:C#窗口程序中嵌入网页调用js