RontoKing
RontoKing

Reputation: 49

C# how to google something without opening the browser, and then go to the first search result?

Without the user seeing the browser window? I want the program to search for something secretly on the internet and copy the text of the first website as the search result.

Upvotes: 1

Views: 796

Answers (2)

John Koerner
John Koerner

Reputation: 38077

You can use the I'm Feeling Lucky URL and an HttpWebRequest:

    public Uri GetFirstResult(string term)
    {
        // Use the I'm Feeling Lucky URL
        var url = string.Format("https://www.google.com/search?num=100&site=&source=hp&q={0}&btnI=1", term);

        HttpWebRequest req = HttpWebRequest.CreateHttp(url);
        return req.GetResponse().ResponseUri;
    }

Upvotes: 3

COLD TOLD
COLD TOLD

Reputation: 13579

You need to use Goodle API for that.

https://code.google.com/p/google-api-for-dotnet/

Upvotes: 1

Related Questions