问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Web;usingSystem.Text.RegularExpressions;namespaceDemo{publicpartialclassForm1:Form{stringtxtstring;publicForm1(){InitializeComponent();}WebBrowserwb;privatevoidbutton1_Click(objectsender,EventArgse){System.Diagnostics.Process.Start("IEXPLORE.EXE","http://www.baidu.com/s?wd=site%3Awww.vip-hacker.com");this.label1.Text=txtstring;}privatevoidForm1_Load(objectsender,EventArgse){wb=newWebBrowser();wb.Navigate("http://www.baidu.com/s?wd=site%3Awww.vip-hacker.com");if(wb!=null){HtmlElementtb=wb.Document.GetElementById("page");//可以通过标签类型,标签Id,标签相对位置找到txtstring=tb.InnerText;//page就是找到相关结果数}else{MessageBox.Show("asd");}}}}报错空指针!~~
解决方案
解决方案二:
同问类似问题