在控制台C#中使用Web浏览器 [英] using web browser in console c#

查看:296
本文介绍了在控制台C#中使用Web浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下形式的代码,我需要将其转换为控制台应用程序...我该怎么做?

i have the following code in forms and i need to convert it to a console application... How can i do this?

private void Form1_Load(object sender, EventArgs e)
        {
            WebBrowser wb = new WebBrowser();

            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DisplayText);


            wb.Url = new Uri("http://www.dut.ac.za");
            wb.Visible = false;
        }

        private void DisplayText(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser wb = (WebBrowser)sender;

            wb.Document.ExecCommand("SelectAll", false, null);

            wb.Document.ExecCommand("Copy", false, null);

            textResultsBox.Text = Clipboard.GetText();
        }

推荐答案

这意义非零. Web浏览器本质上是图形的.您如何建议通过非图形控制台使用图形表单组件?因为您正在与返回的页面进行交互,所以这样做根本没有意义.
This makes zero sense. A web browser is by nature graphical. How do you propose to use a graphical forms component from a non graphical console? Because you are interacting with the page you get back, there really is no point in doing that.


^ ]
http://stackoverflow.com/questions/6324810/using-webbrowser-in-a-控制台应用程序 [ ^ ]
http://stackoverflow.com/questions/4269800/webbrowser-control- in-a-new-thread/4271581#4271581 [ ^ ]
http://izlooite.blogspot.com/2010/04/webbrowser-control- in-console-app.html [ ^ ]
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/57a7cacb-9b89-4d69-a3f3-ff143e0ad2fc[^]
http://stackoverflow.com/questions/6324810/using-webbrowser-in-a-console-application[^]
http://stackoverflow.com/questions/4269800/webbrowser-control-in-a-new-thread/4271581#4271581[^]
http://izlooite.blogspot.com/2010/04/webbrowser-control-in-console-app.html[^]


这篇关于在控制台C#中使用Web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆