Module: GScraper::Search

Defined in:
lib/gscraper/search/page.rb,
lib/gscraper/search/query.rb,
lib/gscraper/search/result.rb,
lib/gscraper/search/search.rb,
lib/gscraper/search/web_query.rb,
lib/gscraper/search/ajax_query.rb,
lib/gscraper/search/exceptions/blocked.rb

Defined Under Namespace

Classes: AJAXQuery, Blocked, Page, Query, Result, WebQuery

Class Method Summary collapse

Class Method Details

.ajax_query(options = {}) {|query| ... } ⇒ Object

Creates a new AJAX query.

Examples:

Search.ajax_query(:query => 'ruby')

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (query)

    If a block is given, the new AJAX query will be passed to it.

Yield Parameters:

See Also:



102
103
104
# File 'lib/gscraper/search/search.rb', line 102

def Search.ajax_query(options={},&block)
  AJAXQuery.new(options,&block)
end

.ajax_query_from_url(url) {|query| ... } ⇒ Object

Creates a AJAX query from a given search URL.

Parameters:

  • url (URI::HTTP)

    The search URL.

Yields:

  • (query)

    If a block is given, the new AJAX query will be passed to it.

Yield Parameters:

See Also:



120
121
122
# File 'lib/gscraper/search/search.rb', line 120

def Search.ajax_query_from_url(url,&block)
  AJAXQuery.from_url(url,&block)
end

.query(options = {}) {|query| ... } ⇒ WebQuery

Creates a new web-query.

Examples:

Search.query(:query => 'ruby', :with_words => 'sow rspec')
Search.query(:exact_phrase => 'fluent interfaces') do |q|
  q.within_past_week = true
end

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Yields:

  • (query)

    If a block is given, it will be passed the new web-query.

Yield Parameters:

  • query (WebQuery)

    The new web query.

Returns:

See Also:



51
52
53
# File 'lib/gscraper/search/search.rb', line 51

def Search.query(options={},&block)
  WebQuery.new(options,&block)
end

.query_from_url(url) {|query| ... } ⇒ WebQuery

Creates a web-query from a search URL.

Examples:

Search.query_from_url('http://www.google.com/search?q=ruby+zen)
Search.query_from_url('http://www.google.com/search?q=ruby') do |q|
  q.within_last_month = true
  q.occurs_within = :title
end

Parameters:

  • url (String)

    The search URL.

Yields:

  • (query)

    If a block is given, it will be passed the new web-query.

Yield Parameters:

  • query (WebQuery)

    The new web query.

Returns:

See Also:



81
82
83
# File 'lib/gscraper/search/search.rb', line 81

def Search.query_from_url(url,&block)
  WebQuery.from_url(url,&block)
end