我尝试使用webbrowser浏览网址列表并获取列表htmldocument并使用此代码:
WebBrowser webBrowser1 = new WebBrowser();
private void Form1_Load(object sender, EventArgs e)
{
string[] url = new string[] { @"http://x2.blogtruyen.com/2010/07/gto-shonan-14-days-chap-22.html", @"http://x2.blogtruyen.com/2010/07/gto-shonan-14-days-chap-23.html", @"http://x2.blogtruyen.com/2010/10/gto-shonan-14-days-chap-24.html" };
foreach (string item in url)
{
webBrowser1.Navigate(new Uri(item));
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (this.webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
string s = "";
HtmlDocument doc = webBrowser1.Document;
HtmlElementCollection images = doc.Images;
foreach (HtmlElement item in images)
{
s += item.GetAttribute("src") + "\r\n";
}
MessageBox.Show(s);
s = "";
}
}
但是当我运行我的应用程序时,它无法正常工作!
我的问题:如何解决这个问题! 感谢提前!
答案 0 :(得分:1)
嗯,首先“它不能正常工作”并没有告诉我们什么是不工作的。
接下来,运用我的心灵力量......