Ce code ne tourne pas avec l'erreur suivante:GetElementsByTagName ne parvient pas à exécuter
An unhandled exception of type 'System.NullReferenceException' occurred in Miner_W.exe
Additional information: Object reference not set to an instance of an object.
public void obturl()
{
string url="http://www.google.com";
WebBrowser wb = new WebBrowser();
wb.Navigate (new Uri (url));
HtmlElementCollection elementcolls = wb.Document.GetElementsByTagName("img");
foreach (HtmlElement elementcoll in elementcolls)
{
listBox1.Items.Add(elementcoll.GetAttribute("scr"));
}
/*string result = elementcoll[i].GetAttribute("src");*/
}
Génial! Ça marche. BTW, pourriez-vous me dire quelle est la fonction du symbole "+, =>" dans l'instruction "wb.DocumentCompleted + = (s, e) =>" – Megaman
@Thomasshi - '+ =' - [subscribe] (https: //msdn.microsoft.com/en-us/library/ms366768.aspx) à l'événement. '=>' - [lambda] (https://msdn.microsoft.com/fr-fr/library/bb311046.aspx). –