GOOGLE SEARCH C# WITHOUT API
HOW TO SEARCH ON GOOGLE IN C# (WITHOUT API)
STEPS:
1) DOWNLOAD AND INSTALL VISUAL STUDIO (SEARCH ON YOUTUBE HOW TO INSTALL AND DOWNLOAD IT)
2)AFTER INSTALLING IT,RUN VISUAL STUDIO AND THEN SELECT A NEW PROJECT AND A POP UP WINDOW IS OPENED AND THEN SELECT VISUAL C#
3) AFTER SELECTING VISUAL C#, SELECT CONSOLE APPLICATION AND NAME IT AS GIVEN BELOW:
WHEN YOU'RE DONE WRITE THE CODE HIGHLIGHTED WITH RED COLOR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;using System.Threading;
namespace ConsoleApplication1 (here the name occurs you write in 3rd step)
{
class program
{
static void main(String args[])
{
String search;
SearchGoogle(search);
/*here you can write in output what you wanna search like the given picture:*/
}
public static void SearchGoogle(string query)
{
Process.Start("http://www.google.com/search ?q=" + query);
}
}
}
EXPLANATION :
1) We use these two libraries using System.Diagnostics; using System.Threading;
to active the process we want to perform, it can be used for multiple purpose but right now we want it only to search on google.
2)Coming towards the SearchGoogle method, here what we are doing is:
a)First we pass the parameter namely query in this method of data-type string in the round braces() ,which means whatever we have to search we'll write it in ("inverted commas") for eg: SearchGoogle("one");
3)Now we used Process.Start to start the process in our case to start searching for the specific word we write inside the round braces ().
4)The link inside (http://www.google.com/search ?q=) :
defines the search engine link of google. and we concatenate the query which is a Local Variable(local variable: anything passed inside the methods round braces is called Local Variable) . so whatever we'll write in a round braces of SearchGoogle("cats") the cat will store inside the query variable and the link will go for a search with a name called cats.
I WISH YOU GUYS LIKE THIS SMALL CODING STUFF.
DON'T FORGET TO FOLLOW ME!
IF YOU'VE ANY CONFUSION REGARDING THIS,DO COMMENTS AND I'LL SURELY REPLY YOU ALL!
THANKS!
REGARDS :
M.MASHOOD SIDDIQUIE
defines the search engine link of google. and we concatenate the query which is a Local Variable(local variable: anything passed inside the methods round braces is called Local Variable) . so whatever we'll write in a round braces of SearchGoogle("cats") the cat will store inside the query variable and the link will go for a search with a name called cats.
I WISH YOU GUYS LIKE THIS SMALL CODING STUFF.
DON'T FORGET TO FOLLOW ME!
IF YOU'VE ANY CONFUSION REGARDING THIS,DO COMMENTS AND I'LL SURELY REPLY YOU ALL!
THANKS!
REGARDS :
M.MASHOOD SIDDIQUIE
Nice , Good job
ReplyDeleteHowever a lighter color would make it easier to read the code.
Oh yeah will update it in a while Thanks!
DeleteI hope you like this