Sha256: a8d63c86e418c03653c3e8a0535d0f16030f2b9a96ab5f5d880ac1e2b36373f5
Contents?: true
Size: 853 Bytes
Versions: 5
Compression:
Stored size: 853 Bytes
Contents
module Krawler module Authentication def authenticate(agent, user, password, login_url) agent.get(login_url) do |page| login_form = page.form login_form['user[email]'] = user login_form['user[password]'] = password agent.submit(login_form, login_form.buttons.first) end end def use_authentication? !@username.nil? || !@password.nil? || !@login_url.nil? end def validate_authentication_options any_nil = [@login_url, @username, @password].any? {|v| v.nil?} all_nil = [@login_url, @username, @password].all? {|v| v.nil?} if (any_nil && !all_nil) puts "You must either provide all authentication options" + " (username, password, and loginurl) or provide none." return false else return true end end end end
Version data entries
5 entries across 5 versions & 1 rubygems