C#操作网页, 这几行代码不明白

来源:百度知道 编辑:UC知道 时间:2024/06/16 23:51:36
想学习用C#操作网页,无耐教程难找,只好找代码边作边理解吧。
可是这有些不懂。
private void button1_Click(object sender, EventArgs e)
{
//object url=\"http://www.google.com\";
//object nothing=null;
//this.axWebBrowser1.Navigate2(ref url,ref nothing,ref nothing,ref nothing,ref nothing); //???
//this.axWebBrowser1.DownloadComplete+=new System.EventHandler(this.button2_Click); //这里不明白,做什么的
string url="http://www.google.com";
this.axWebBrowser1.Navigate(url);

}

private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text="";
mshtml.IHTMLDocument2 doc=(mshtml.IHTMLDocument2)this.axWebBrowser1.D

1.
//this.axWebBrowser1.Navigate2(ref url,ref nothing,ref nothing,ref nothing,ref nothing);

axWebBrowser1.Navigate()
axWebBrowser1.Navigate2()
导航(跳转)到指定的URL。Navigate2比Navigate功能更多。

2.
//this.axWebBrowser1.DownloadComplete+=new System.EventHandler(this.button2_Click); //这里不明白,做什么的

动态事件绑定
把axWebBrowser1.DownloadComplete事件绑定到button2_Click()方法
发生axWebBrowser1.DownloadComplete事件时,调用button2_Click()方法进行处理

3.
this.textBox1.Text+=element.innerHTML; //???是给什么赋 值吗??

这个是赋值
element.innerHTML 表示元素内部的Html代码
比如
<div>
<a href="http://www.baidu.com">百度</a>
</div>
div元素的innerHTML就是: <a href="http://www.baidu.com">百度</a>

4.转型那个不清楚
大概就是axWebBrowser1.Document