I'm trying to make a bot that goes on to a streaming site, and downloads stuff from there for me. The thing is that it's behaving weirdly, i'm searching for elements using a foreach loop, since the elements only have classes and not ids. The weird thing is that i need to put MessageBox.Show() before the foreach loops, otherwise it won't do anything.
Code(C#):
private void startDownload()
{
infoLabel5.Text = "Download started on series: " + series;
infoLabel5.ForeColor = Color.Black;
browser.ScriptErrorsSuppressed = true;
browser.Navigate("http://www.anilinkz.tv");
browserProgress.Increment(10);
var elements = browser.Document.GetElementsByTagName("input");
MessageBox.Show("set value");
foreach (HtmlElement element in elements)
{
if (element.GetAttribute("classname") == "query")
{
element.SetAttribute("value", series);
downloadStep2();
}
}
}
private void downloadStep2()
{
infoLabel5.Text = "Download started on series: " + series;
infoLabel5.ForeColor = Color.Black;
browserProgress.Increment(5);
var elements = browser.Document.GetElementsByTagName("input");
MessageBox.Show("Click");
foreach (HtmlElement element in elements)
{
if (element.GetAttribute("classname") == "searchbtn")
{
element.InvokeMember("click");
}
}
}
And sometimes it will out of the blue, tell me that var elements had a null reference exception.