Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding globalize option to the request

  • Loading branch information...
commit dcd64baf922080e8eb45107039f98f6856493c9c 1 parent d093af6
@staskie authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/ruby-web-search.rb
View
7 lib/ruby-web-search.rb
@@ -28,7 +28,7 @@ def self.unthreaded_search(options={})
end
class Query
- attr_accessor :query, :start_index, :result_size, :filter, :country_code, :language_code
+ attr_accessor :query, :start_index, :result_size, :filter, :country_code, :language_code, :global
attr_accessor :safe_search, :type, :custom_search_engine_id, :version, :referer, :request_url
attr_accessor :size, :cursor, :custom_request_url, :response
@@ -77,6 +77,7 @@ def initialize(options={})
@version = options[:version] || "1.0"
@referer = options[:referer] || "http://github.com/mattetti/"
@size = options[:size] || 4
+ @global = options[:global]
@result_size = "large" if size > 4 # increase the result set size to avoid making too many requests
@size = 8 if (@result_size == "large" && size < 8)
end
@@ -92,6 +93,7 @@ def build_request
@request_url << "&start=#{cursor}" if cursor > 0
@request_url << "&lr=#{language_code}" if language_code
@request_url << "&hl=#{country_code}" if country_code
+ @request_url << "&gl=#{global}" if global
puts request_url if $RUBY_WEB_SEARCH_DEBUG
request_url
@@ -110,6 +112,7 @@ def build_requests
url << "&rsz=#{result_size}" if result_size
url << "&lr=#{language_code}" if language_code
url << "&hl=#{country_code}" if country_code
+ url << "&gl=#{global}" if global
url << "&start=#{cursor}"
@cursor += 8
requests << url
@@ -538,4 +541,4 @@ def limit(req_size)
end #of Bing
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.