Class: Plagiarism::Strategies::Bing
- Defined in:
- lib/plagiarism/strategries/bing.rb
Constant Summary collapse
- URL =
'https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web'
Constants inherited from Engine
Instance Attribute Summary
Attributes inherited from Engine
Class Method Summary collapse
Methods inherited from Engine
exists?, #initialize, #match, #retrieve_link, #unique?, valid_segments, whitelists_regex
Constructor Details
This class inherits a constructor from Plagiarism::Strategies::Engine
Class Method Details
.fetch(content, params) ⇒ Object
8 9 10 |
# File 'lib/plagiarism/strategries/bing.rb', line 8 def fetch(content, params) Typhoeus.get(URL, params: params.merge('$format' => :json, 'Query' => "'#{content}'"), userpwd: ":#{Config.bing_key}") end |
.iterate(response, action = :all?) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/plagiarism/strategries/bing.rb', line 12 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 |