Sha256: 64ceb240f65b00e6a22d204f7ec4caa66e42a024f2f9b8b154e5d49443e11dd5

Contents?: true

Size: 978 Bytes

Versions: 6

Compression:

Stored size: 978 Bytes

Contents

module GovKit
  module SearchEngines
    class GoogleBlog
      def self.search(query=[], options = {})
        query = [query, options[:geo]].compact.join('+')
        host = GovKit::configuration.google_blog_base_url
        path = "/blogsearch_feeds?q=#{URI::encode(query)}&hl=en&output=rss&num=50"

        doc = Nokogiri::XML(make_request(host, path))

        mentions = []

        doc.xpath('//item').each do |i|
          mention = GovKit::Mention.new
          mention.title = i.xpath('title').inner_text
          mention.search_source = 'Google Blogs'
          mention.date = i.xpath('dc:date').inner_text
          mention.excerpt = i.xpath('description').inner_text
          mention.source = i.xpath('dc:publisher').inner_text
          mention.url = i.xpath('link').inner_text

          mentions << mention
        end
        mentions
      end

      def self.make_request(host, path)
        response = Net::HTTP.get(host, path)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
govkit-0.7.4 lib/gov_kit/search_engines/google_blog.rb
govkit-0.7.3 lib/gov_kit/search_engines/google_blog.rb
govkit-0.7.2 lib/gov_kit/search_engines/google_blog.rb
govkit-h-0.7.1.0 lib/gov_kit/search_engines/google_blog.rb
govkit-0.7.1 lib/gov_kit/search_engines/google_blog.rb
govkit-0.7.0 lib/gov_kit/search_engines/google_blog.rb