I am trying to develop an automated bot in VS 2015 using C#. I have web browser control, 1 listbox, 1 textbox, 1 button. Now on button click, I want to ask is it possible to automatically iterate through the listbox items one by one (I mean select 1 item from listbox then send that string to google then select next item from listbox do the same and so on) and sending that string to google search engine in my web browser control and if google show results regarding that query then that string will be stored in multiline textbox ?
Can someone suggest me how is it possible ? Below is my code:
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("http://www.bing.com/?scope=web&mkt=en-US");
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
if (listBox1.SelectedIndex <= listBox1.Items.Count - 0)
{
HtmlDocument htmlDoc = webBrowser1.Document;
webBrowser1.Document.All["sb_form_q"].InnerText = listBox1.Text;
webBrowser1.Document.GetElementById("sb_form_go").InvokeMember("click");
}
}
}