分好少啊,算了webBrowser1.Document.GetElementById("kw").SetAttribute("value", "C#");//输入关键词
webBrowser1.Document.GetElementById("su").InvokeMember("click");//点击查询
//下一页的按钮由于没有ID,所以通过class名字来查找
var elList = webBrowser1.Document.GetElementsByTagName("a");
            foreach (HtmlElement el in elList)
            {
                if (el.GetAttribute("class") == "n")
                {
                    el.InvokeMember("click");
                    return;
                }
            }

解决方案 »

  1.   

    在private void button2_Click(object sender, EventArgs e)中填写给的内容后:
    webBrowser1.Document.GetElementById("kw").SetAttribute("value", "C#");//输入关键词中的SetAttribute("value", "C#");里面的value和c#都代表什么?而且这样做运行后出现未处理NullReferenceException(未将对象引用设置到对象的实例)该怎么改呢!
      

  2.   

    SetAttribute("value", "C#"),是指设置value的属性值为"C#"。
    你得先导航到百度,在调用赋值
      

  3.   

    SetAttribute("value", "C#"),是指设置value的属性值为"C#"。
    你得先导航到百度,在调用赋值
    关键是获取input中的id"kw",在那一行中没有value属性,该怎么办呢
    (<input type=text name=wd id=kw1 maxlength=100 style="width:474px;" autocomplete=off>)
      

  4.   

    SetAttribute("value", "C#"),是指设置value的属性值为"C#"。
    你得先导航到百度,在调用赋值
    关键是获取input中的id"kw",在那一行中没有value属性,该怎么办呢
    (<input type=text name=wd id=kw1 maxlength=100 style="width:474px;" autocomplete=off>)没有value属性,SetAttribute会给他添加这个属性