forked from ashbb/ruby_learning_participants
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# ruby_launcher.rb | ||
# usage: ruby ruby_launcher.rb FORPC101-8C | ||
# | ||
# NOTE: replace your username and passowrd, line 13 and 14 | ||
|
||
require 'mechanize' | ||
|
||
agent = WWW::Mechanize.new | ||
|
||
login_page = agent.get("http://rubylearning.org/class/login/index.php") | ||
|
||
login_form = login_page.forms.first | ||
login_form['username'] = "username" | ||
login_form['password'] = "password" | ||
main_page = agent.submit(login_form) | ||
|
||
course_link = main_page.links.text(ARGV[0].upcase) | ||
course_link.shift if course_link.length == 3 | ||
course_page = agent.get(course_link.href) | ||
|
||
participants_link = course_page.links.text('Participants') | ||
participants_page = agent.get(participants_link.href) | ||
|
||
show_all_text = participants_page.search("//div[@id='showall']").inner_text | ||
show_all_link = participants_page.links.text(show_all_text) | ||
show_all_page = agent.get(show_all_link.href) | ||
|
||
open('show_all_page.html', 'w'){|f| f.puts show_all_page.body} | ||
|
||
%x(ruby shoes_countries_new.rb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters