请问各位大侠!
string phoneNum = tbPhoneNum.Text;
this.webPhoneGet.Url = new Uri("http://www.ip138.com:8080/search.asp?mobile=" + phoneNum + "&action=mobile");我现在获取了手机归属地网页了。剩下的就是获取里面的 地区信息了。
请问在后台如何获取网页上面的内容,我不需要把网页写到什么地方去,我想知道用什么办法可以在断点里面看到网页的内容,然后扣下 我需要的信息 谢谢!
string phoneNum = tbPhoneNum.Text;
this.webPhoneGet.Url = new Uri("http://www.ip138.com:8080/search.asp?mobile=" + phoneNum + "&action=mobile");我现在获取了手机归属地网页了。剩下的就是获取里面的 地区信息了。
请问在后台如何获取网页上面的内容,我不需要把网页写到什么地方去,我想知道用什么办法可以在断点里面看到网页的内容,然后扣下 我需要的信息 谢谢!
这个我试过了 没用
string phoneNum = tbPhoneNum.Text;
this.webPhoneGet.Url = new Uri("http://www.ip138.com:8080/search.asp?mobile=" + phoneNum + "&action=mobile");
HtmlDocument hd = webPhoneGet.Document;
......
请问还有哪位大侠看看怎么搞 谢谢
mshtml.HTMLDocument htmldocument = (mshtml.HTMLDocument)webBrowser.Document.DomDocument;
string temp = htmldocument.documentElement.outerHTML;
byte[] buffer = Encoding.GetEncoding(webBrowser.Document.Encoding).GetBytes(temp);
MemoryStream ms = new MemoryStream(buffer);
htmlDocument.Load(ms, Encoding.GetEncoding(webBrowser.Document.Encoding));
return htmlDocument;只能获取静态页内容。其实就是获取编码 internal string CurrentEncoding
{
get
{
return webBrowser.Document.Encoding;
}
}
HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
htmlDocument.Load(webBrowser.DocumentStream, Encoding.GetEncoding(CurrentEncoding));
return htmlDocument;
while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}得用这个确保页面加载结束
上面的大侠 你们说清楚点啊 我都试过了 怎么不行的啊? mshtml .dll 下载添加不了C# code 里面的内容试过了怎么不行的啊
this.webPhoneGet.Url = new Uri("http://www.ip138.com:8080/search.asp?mobile=" + phoneNum + "&action=mobile");
while (webPhoneGet.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
string content = webPhoneGet.Document.Body.InnerHtml;
谢谢 :tidalmelon 这位大侠 多了你那个while就可以的了 !