Sha256: 8d6c21720e8d1598bce12b06f0e875a4c5e69529ec304db654ec4f0a1e9ea7d6

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 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 exists?(response)
          results = JSON.parse(response)['d']['results'] rescue []
          results.all? do |r|
            uri = URI.parse URI::encode(r['Url'])
            uri.host =~ whitelists_regex
          end
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plagiarism2-0.0.5 lib/plagiarism/strategries/bing.rb
plagiarism2-0.0.4 lib/plagiarism/strategries/bing.rb