first google result url c#

Viewed 43

My idea was to create a program that takes the titles of some movies from a txt file and googles the title + imbd in order to be sure that the first title is imbd after which it should save the title on another txt file title-link imbd pair of type (https://www.imdb.com/title/tt0166813/). For now I still haven't figured out how to get the link of the first google result. I looked at Selenium, HtmlAgilityPack etc but didn't find this feature.

private void button3_Click(object sender, EventArgs e)
        {
            //START-BUTTON

           
            /*Read the file and display it line by line.  
            foreach (string line in System.IO.File.ReadLines(fileName))
            {
               // System.Console.WriteLine(line);
                counter++;
            }*/

            
            var uri = "https://www.google.com/search?q=" + "spirit"+"  "+"imbd";
            var psi = new System.Diagnostics.ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = uri;
            System.Diagnostics.Process.Start(psi);


        }

Last thing in C # is there a way to transfer a variable from another class not using global variables? For the ProgressBar I would need to know the total number of titles in the file.

fileName it should be a variable (public perhaps) so that it can be reused in other classes like the one above. Thanks in advance to anyone who will help me, sorry if I am asking very simple things for some of you, but I am not a C # expert I had created a program similar to this on Python using BeautifulSoup which has a "first_link" functionality but I wanted to recreate the program on C # because it is easier to create a graphical interface

private void button1_Click(object sender, EventArgs e)
        {
            //READ-BUTTON
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string fileName;
                fileName = dlg.FileName;
                MessageBox.Show("Questo e' il nome dell'INPUT" +"   " +  fileName);
                //

            }
            System.Diagnostics.Process.Start(dlg.FileName);
            
   }
0 Answers
Related