How to “render” HTML without WebBrowser control

匆匆过客 提交于 2020-01-04 16:58:31

问题


First at all - I don't know if "render" is the right word. I like to get information from an website. At the moment therefore I use the WebBbrowser control. Now I like to use HttpWebRequests because I think, that's much faster and threading could be used more easily. But I can't use them, because the HTML-output string I receive from HttpWebRequest has got a lot of JavaScript inside from which the information, that I need, will be created. The web browser "renders" the JavaScript to readable HTML. How to do this step "by hand", so that I can use HttpWebRequests?

I hope you understand, what I want.


回答1:


so if you need the javascript rendering engine i suggest you have a look at selenium project.




回答2:


I solved my problem with a project called Awesomium. In this thread you will find all you need to get html with executed javascript. The "special part" is this one:

var sourceVal = webView.ExecuteJavascriptWithResult( "document.getElementsByTagName('html')[0].outerHTML;" );

if ( sourceVal != null )
{
    using ( sourceVal )
    {
        html = sourceVal.ToString();
    }
}


来源:https://stackoverflow.com/questions/10562051/how-to-render-html-without-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!