Sha256: 0b85c36bf5743894709720f3fe40b63c8e23a70e2984800c35af41b69f098dde
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require "curb" require "uri" require "tempfile" module CourseraDownloader class Course attr_reader :cookie_file def initialize(name) @name = name @cookie_file = Tempfile.new('coursera_cookies') end def login(email, password) curl = Curl::Easy.new curl.verbose = false curl.enable_cookies = true curl.cookiefile = @cookie_file.path curl.cookiejar = @cookie_file.path curl.follow_location = true curl.url = login_redirect_url curl.http_get curl.url = curl.last_effective_url curl.http_post([ Curl::PostField.content('email', email), Curl::PostField.content('password', password), Curl::PostField.content('login', "Login") ]) curl.follow_location = false curl.url = index_url.to_s curl.http_get response_code = curl.response_code curl.close response_code == 200 end def index_url URI.parse("#{host_url}/#{@name}/class/index") end private def host_url "https://class.coursera.org" end def login_redirect_url "#{host_url}/#{@name}/auth/auth_redirector?type=login&subtype=normal&email=&visiting=&minimal=true" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
coursera_downloader-1.0.0 | lib/coursera_downloader/course.rb |