Пример #1
0
        public SearchResult Parse(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException("content not be null -or- content not be empty");
            }

            var queryResults = JsonConvert.DeserializeObject<GooglePlusMap>(content);
            IList<ResultItem> results = new List<ResultItem>();
            foreach (ItemResult currentResult in queryResults.Items)
            {
                if (currentResult.Object.Type.Equals("note") && !string.IsNullOrEmpty(currentResult.Object.Content))
                {
                    var current = new ResultItem
                    {
                        Date = currentResult.Published,
                        Url = currentResult.Url,
                        Author = currentResult.Actor.DisplayName,
                        Snippet = currentResult.Object.Content,
                        Title = currentResult.Title
                    };
                    results.Add(current);
                }
            }

            return new SearchResult
            {
                Items = results,
                HasNextPage = !string.IsNullOrEmpty(queryResults.NextPageToken),
                Parameters = new Dictionary<string, string> { { "pageToken", queryResults.NextPageToken } }
            };
        }
Пример #2
0
        protected override SearchResult ExtractResultsFromHtml(HtmlNode parentNode)
        {
            if (parentNode == null)
            {
                return new SearchResult();
            }

            var results = new List<ResultItem>();

            foreach (var node in parentNode.ChildNodes.Where(l => l.FirstChild.Name == "div"))
            {
                try
                {
                    var result = new ResultItem
                    {
                        Url = this.ExtractUrl(node),
                        Date = this.ExtractDate(node),
                        Snippet = this.ExtractSnippet(node),
                        Title = this.ExtractTitle(node),
                        Author = this.ExtractAuthor(node)
                    };
                    results.Add(result);
                }
                catch (Exception e)
                {
                    throw new ParserException(e.Message) { Source = e.Source };
                }
            }
            return new SearchResult { Items = results, HasNextPage = this.hasNextPage };
        }
Пример #3
0
        protected override SearchResult ExtractResultsFromHtml(HtmlNode parentNode)
        {
            if (parentNode == null)
            {
                return new SearchResult { Items = new List<ResultItem>() };
            }

            var results = new List<ResultItem>();
            foreach (HtmlNode node in parentNode.ChildNodes.Where(c => c.Name == "li"))
            {
                if (this.IsValidNode(node))
                {
                    var result = new ResultItem
                    {
                        Url = this.ExtractUrl(node),
                        Date = this.ExtractDate(node),
                        Snippet = this.ExtractSnippet(node),
                        Title = this.ExtractTitle(node),
                        Author = this.ExtractAuthor(node)
                    };
                    results.Add(result);
                }
            }

            return new SearchResult { Items = results, HasNextPage = this.hasNextPage };
        }
Пример #4
0
        public SearchResult Parse(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException("content not be null -or- content not be empty");
            }

            var queryResults = JsonConvert.DeserializeObject<TwitterMap>(content);
            IList<ResultItem> results = new List<ResultItem>();
            foreach (TwittResult currentResult in queryResults.Results)
            {
                var current = new ResultItem
                {
                    Date = currentResult.CreatedAt,
                    Url = string.Format("http://www.twitter.com/{0}/statuses/{1}", currentResult.FromUser, currentResult.Id),
                    Author = currentResult.FromUser,
                    Snippet = currentResult.Text,
                    Title = currentResult.Title
                };
                results.Add(current);
            }

            return new SearchResult { Items = results, HasNextPage = !string.IsNullOrEmpty(queryResults.NextPage) };
        }
Пример #5
0
        public SearchResult Parse(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException("content not be null -or- content not be empty");
            }
            var diggResult = JsonConvert.DeserializeObject<DiggMap>(content);

            var results = new List<ResultItem>();
            foreach (DiggStory currentResult in diggResult.Stories)
            {
                var current = new ResultItem
                {
                    Date = currentResult.CreatedTime,
                    Url = currentResult.Link,
                    Author = currentResult.User.Name,
                    Snippet = currentResult.Description,
                    Title = currentResult.Title
                };
                results.Add(current);
            }

            return new SearchResult { Items = results };
        }
Пример #6
0
        public SearchResult Parse(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException("content not be null -or- content not be empty");
            }

            var results = new List<ResultItem>();
            var facebookResult = this.GetFacebookResult(content);

            foreach (FacebookPost currentResult in facebookResult.Posts.Where(p => p.Type.Equals(AcceptType)))
            {
                var current = new ResultItem
                {
                    Date = currentResult.CreatedTime,
                    Url = string.Format("http://www.facebook.com/profile.php?id={0}", currentResult.Author.Id),
                    Author = currentResult.Author.Name,
                    Snippet = currentResult.Message ?? currentResult.Description,
                    Title = currentResult.Name
                };
                results.Add(current);
            }
            return new SearchResult { Items = results };
        }