Sha256: b13c15d41c22d44210fac9f32afdc37a5371d488de0e2aa06e2ec79b4e9c4d08

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

require 'gscraper/gscraper'

module GScraper
  module WebAgent
    protected

    #
    # Returns the WWW::Mechanize agent.
    #
    def web_agent(&block)
      @web_agent ||= GScraper.web_agent

      block.call(@web_agent) if block
      return @web_agent
    end

    #
    # Fetches the specified _url_, with the given _referer_ using the
    # web_agent.
    #
    #   get_page('http://www.hackety.org/')
    #
    def get_page(url,referer=nil,&block)
      web_agent.get(url,referer,&block)
    end

    #
    # Posts the specified _url_ and the given _query_ parameters using the
    # web_agent.
    #
    #   post_page('http://www.wired.com/', :q => 'the future')
    #
    def post_page(url,query={})
      web_agent.post(url,query)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gscraper-0.1.7 lib/gscraper/web_agent.rb
gscraper-0.1.6 lib/gscraper/web_agent.rb