Click here to Skip to main content
15,886,872 members
Articles / Programming Languages / C#

LINQ To Google Image and Google Groups

Rate me:
Please Sign up or sign in to vote.
5.00/5 (17 votes)
8 May 200710 min read 91K   400   48  
A LINQ Implementation for Google Images/Groups Search
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using System.Linq;
using System.Linq.Expressions;

using MChen.Linq.GoogleSearch;
using MChen.Linq.GoogleSearch.Common;
using MChen.Linq.GoogleSearch.Images;
using MChen.Linq.GoogleSearch.Groups;

namespace MChen.Linq.GoogleSearch.Test
{
    class Program
    {
        public static IEnumerable TestImage()
        {
            var test = from img in Google.Images
                       where img.RelatesTo("microsoft")
                       select new { img.Rank, img.Url };
            return test;
        }

        public static IEnumerable TestGroup()
        {
            var test = from msg in Google.Groups
                       where msg.Description.Contains("Microsoft")
                           && msg.Group == "comp.os.*"
                            && msg.Subject.Contains("Windows")
                            && msg.PostDate > DateTime.Parse("01/01/2007")
                            && msg.PostDate < DateTime.Parse("05/01/2007")
                       orderby msg.Rank
                       select new { msg.Rank, msg.PostDate, msg.Subject };
            return test;
        }

        static void Main(string[] args)
        {
            var res = TestImage();

            int cnt = 0;
            foreach (var img in res)
            {
                cnt++;
                Console.WriteLine(img);
                if (cnt == 15) break;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States

Comments and Discussions