System.Windows.Forms.WebBrowser wb =
new
System.Windows.Forms.WebBrowser();
wb.Navigate(
"www.imdb.com"
);
wb.Stop();
wb.Document.GetElementById(
"navbar-query"
).SetAttribute(
"value"
, textBox1.Text);
HtmlElement acceptButton = wb.Document.GetElementById(
"navbar-submit-button"
if
(acceptButton !=
null
)
{
acceptButton.InvokeMember(
"click"
}
HtmlElementCollection tables = wb.Document.GetElementsByTagName(
"table"
try
(tables.Count <= 0)
return
;
HtmlElementCollection rows = tables[0].GetElementsByTagName(
"tr"
foreach
(HtmlElement row
in
rows)
HtmlElementCollection cells = row.GetElementsByTagName(
"td"
(HtmlElement cell
cells)
String text = cell.InnerText;
(!String.IsNullOrEmpty(text) && !String.IsNullOrWhiteSpace(text))
listBox1.Items.Add(text);
catch
(ArgumentOutOfRangeException exc)
listBox1.Items.Add(exc.Message);
Richard Mueller edited Revision 1. Comment: Removed (en-US) from title, modified title casing, modified tags (comma delimited)
Richard Mueller edited Revision 2. Comment: Replace RGB values with color names in HTML to restore colors