1
Answer

select a random link from google

Photo of william king

william king

11y
918
1
I Have an application that has a text box and a button and when you click the button it open up Ie and Google and searches for what was typed into the text box. but i need it to than select a random link from the generated results every time. Anyone know how to do this? Here is the code i have so far 

namespace Search
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Btn_Click(object sender, RoutedEventArgs e)
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText(_textBox.Text);
                browser.Button(Find.ByName("btnG")).Click();

                browser.WaitForComplete(5000);

                System.Windows.Forms.SendKeys.SendWait("{Enter}"); // presses search on the second screen

                browser.Button(Find.ById("gbqfb")/*.ByName("btnG")*/).Click(); // doesn't work

                

                



              

            }
        }
    }
}

Answers (1)

0
Photo of Ramesh Palanivel
NA 9.5k 138.6k 8y
Hi Santosh,
 
Try this links, It may help you!..
 
https://www.codeproject.com/Tips/607801/SimpleplusChatplusprogramplusinplusC
 
http://www.c-sharpcorner.com/UploadFile/97ec13/how-to-make-a-chat-application-in-C-Sharp/