Sha256: bec4022d18bb74324d29f517cf162ac764533ef5a5697f738f5741c0bcab2398

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

require 'mechanize'
require 'hpricot'

module Adsense
  class Info

    def initialize( username, password )
      @username = username
      @password = password
      @agent = Mechanize::Mechanize.new
    end

    def login!
      page = @agent.get 'http://www.gmail.com'
      form = page.forms.first
      if form
        form.Email = @username
        form.Passwd = @password
        @agent.submit form
      end
      nil
    end

    def today_so_far
      login!
      ( get('https://www.google.com/adsense/v3/m/home') / 'span[@class~=value]' ).first.inner_html
    end

    private

    def get( url )
      Hpricot(@agent.get( url ).body)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adsense-info-1.0.3 lib/adsense-info.rb
adsense-info-1.0.2 lib/adsense-info.rb