从WebBrowser控件获取所有文本 [英] Get all text from WebBrowser control

查看:197
本文介绍了从WebBrowser控件获取所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WebBrowser控件,我想从该控件中获取所有文本。换句话说,我将获得与如果要在哪里握住鼠标的内容相同的文本,请从浏览器中选择所有内容并将其粘贴到记事本中。我知道有几种获取文本的技术,例如WebBrowser.DocumentText或innerhtml,但是这些技术都无法提供与将浏览器中的所有内容复制到剪贴板的文本相同的文本。

I have a WebBrowser control and I will like to get all the text from that control. In other words I will like to get the same text that if I where to grab my mouse select everything from the browser and paste it in notepad. I know there are several techniques to get the text such as WebBrowser.DocumentText or innerhtml but none of those techniques gives the same text that I would get if I where to copy everything from the browser to the clipboard.

推荐答案

这应该起作用:

webBrowser1.Document.ExecCommand("SelectAll", false, null);
webBrowser1.Document.ExecCommand("Copy", false, null);    

这篇关于从WebBrowser控件获取所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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