如果要从网页访问原始HTML,则需要执行以下操作:
使用HttpWebRequest连接到该文件
打开连接并将响应流读入字符串
搜索您的内容的回复
所以代码如下:
string pageContent = null; HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://example.com/page.html"); HttpWebResponse myres = (HttpWebResponse)myReq.GetResponse(); using (StreamReader sr = new StreamReader(myres.GetResponseStream())) { pageContent = sr.ReadToEnd(); } if (pageContent.Contains("YourSearchWord")) { //Found It }