Click here to Skip to main content
15,885,366 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 90.9K   400   48  
A LINQ Implementation for Google Images/Groups Search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MChen.Linq.GoogleSearch.Common
{
    public abstract class Result
    {
        public int Rank { get; internal set; }
        public Uri Url { get; internal set; }
        public string Domain { get; internal set; }
        public string Description { get; internal set; }
    }

    internal abstract class QueryInfo
    {
        public List<string> AllWords = new List<string>();
        public List<string> OrWords = new List<string>();
        public List<string> NotWords = new List<string>();

        public string Domain { get; set; }

        #region private methods
        protected string GetDomain()
        {
            if (Domain == null) return "";
            return Domain;
        }

        protected string GetWords(List<string> list)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string s in list)
                sb.AppendFormat("{0} ", s);
            return sb.ToString();
        }
        #endregion

        public abstract string GetUrl(int start);

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("All:         ");
            foreach (string s in AllWords) sb.AppendFormat("{0}, ", s);
            sb.Append("\n");
            sb.Append("Or:          ");
            foreach (string s in OrWords) sb.AppendFormat("{0}, ", s);
            sb.Append("\n");
            sb.Append("Not:         ");
            foreach (string s in NotWords) sb.AppendFormat("{0}, ", s);
            sb.Append("\n");
            sb.AppendFormat("Domian:      {0}\n", Domain);
            return sb.ToString();
        }
    }
}

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