Sha256: 1e3b85098ab7c83aec0c5665e0957dd64f61557e19e350e77b3ae5d59daedc1e

Contents?: true

Size: 609 Bytes

Versions: 5

Compression:

Stored size: 609 Bytes

Contents

module Plagiarism
  module Strategies
    class Bing < Engine
      URL = 'https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web'

      class << self

        def fetch(content, params)
          Typhoeus.get(URL, params: params.merge('$format' => :json, 'Query' => "'#{content}'"), userpwd: ":#{Config.bing_key}")
        end

        def iterate(response, action = :all?)
          results = JSON.parse(response)['d']['results'] rescue []
          results.send(action) do |r|
            uri = URI.parse URI::encode(r['Url'])
            yield uri
          end
        end

      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
plagiarism2-0.0.11 lib/plagiarism/strategries/bing.rb
plagiarism2-0.0.10 lib/plagiarism/strategries/bing.rb
plagiarism2-0.0.9 lib/plagiarism/strategries/bing.rb
plagiarism2-0.0.8 lib/plagiarism/strategries/bing.rb
plagiarism2-0.0.7 lib/plagiarism/strategries/bing.rb