如何从webbrowser获取数据 [英] How do get data from webbrowser

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

问题描述

我有一个表单和一个webbrowser现在我想检索webbrowser上显示的数据必须做什么?



 <   div     id   =  divTop > ;  

< div id = chart style = width:500px; float:right; > < ; / div >
< div id = grid 样式 = margin-removed 505px;高度:700px; > < / div >

< / div >





我想从div标签中获取内容,但不知道如何

解决方案

尝试使用webBrowse文档的GetElementByID方法

 HtmlElement e1 = webBrowser1.Document.GetElementById(  chart); 
MessageBox.Show(e1.InnerText);


 HtmlElement texts = webBrowser1.Document.GetElementById(text-conent); 
string kq =;
foreach(文本中的var项目)
{
kq + = item.InnerText + Environment.NewLine;
}
richTextBox1.Text = kq;

程序错误[foreach语句不能对类型为system.windows.forms.htmlelement的变量进行轻快删除,因为system.windows.forms.htmlelement不包含GetEnumenrator的公共定义


I have a form and one webbrowser now I want to retrieve data displayed on the webbrowser must do?

<div id="divTop">

    <div id="chart" style="width: 500px; float: right;"></div>
    <div id="grid" style="margin-removed 505px; height: 700px;"></div>

</div>



I want to take content from div tag but do not know how

解决方案

try with GetElementByID method of webBrowse document

HtmlElement e1 = webBrowser1.Document.GetElementById("chart");
MessageBox.Show(e1.InnerText);


HtmlElement texts = webBrowser1.Document.GetElementById("text-conent");
           string kq = "";
           foreach (var item in texts)
               {
                   kq += item.InnerText + Environment.NewLine;
               }
           richTextBox1.Text = kq;

Program error [ foreach statement cannot operetta on variables of type "system.windows.forms.htmlelement" because "system.windows.forms.htmlelement" does not contain a public definition for GetEnumenrator


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

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