Skip to content

Commit

Permalink
Supported the new spec of Mechanize 0.9.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbb committed Jan 11, 2009
1 parent 0c581d8 commit b409ce9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 2,035 deletions.
346 changes: 0 additions & 346 deletions Countries/forpc101-4.html

This file was deleted.

316 changes: 0 additions & 316 deletions Countries/forpc101-5c.html

This file was deleted.

310 changes: 0 additions & 310 deletions Countries/forpc101-6c.html

This file was deleted.

284 changes: 0 additions & 284 deletions Countries/forpc101-7c.html

This file was deleted.

247 changes: 0 additions & 247 deletions Countries/forpc101-8c.html

This file was deleted.

250 changes: 0 additions & 250 deletions Countries/poirpc101-1i.html

This file was deleted.

255 changes: 0 additions & 255 deletions Countries/pojrpc101-1.html

This file was deleted.

21 changes: 11 additions & 10 deletions Countries/ruby_launcher.rb
@@ -1,7 +1,6 @@
# ruby_launcher.rb
# usage: ruby ruby_launcher.rb FORPC101-8C
#
# NOTE: replace your username and passowrd, line 13 and 14
# usage: ruby ruby_launcher.rb POIRPWMC101-2I
# Mechanize compliant version: 0.9.0

require 'mechanize'

Expand All @@ -10,21 +9,23 @@
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"
login_form['username'] = "your username"
login_form['password'] = "your 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_link = main_page.links.text(ARGV[0].upcase)
course_link = main_page.link_with(:text => ARGV[0].upcase)

course_page = agent.get(course_link.href)

participants_link = course_page.links.text('Participants')
participants_link = course_page.link_with(: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_link = participants_page.link_with(: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)
%x(ruby shoes_countries_new.rb)

31 changes: 14 additions & 17 deletions README.txt
@@ -1,36 +1,33 @@
RubyLearning.org Participants' Countries

The NEW version,

Requirement:
This new vesion uses Hpricot and WWW::Mechanize.
This vesion uses Hpricot and Mechanize.

gem install hpricot
gem install mechanize


Usage:
- replace your username and passowrd, line 13 and 14 of ruby_launcher.rb
- input the following command line to launch the ruby program (not Shoes app) - ruby_launcher.rb,
with one argument (course name).
- replace your username and passowrd, line 12 and 13 of ruby_launcher.rb
- input the following command line to launch the ruby program (not Shoes app)
- ruby_launcher.rb, with one argument (course name).

C:\> ruby ruby_launcher.rb FORPC101-8C
C:\> ruby ruby_launcher.rb FORPC101-8C

Change log:
16th Oct: Added 'nostroke' for Shoes-0.r1057

13th Oct: Released new ruby_launcher.rb and shows_countries_new.rb
This new version needs no local data files (i.e. forpc101-7c.html)
It will directly access to the web site (http://rubylearning.org/class/login/index.php)
11th Jan: Supported the new spec of Mechanize 0.9.0. <br>
2009 <br>
16th Oct: Added 'nostroke' for Shoes-0.r1057 <br>
13th Oct: Released new ruby_launcher.rb and shows_countries_new.rb <br>
This new version needs no local data files (i.e. forpc101-7c.html) <br>
It will directly access to the web site (http://rubylearning.org/class/login/index.php) <br>

To do list:
- If the following Shoes feature works well, use it instead of the way launching from ruby.

Shoes.setup do
gem 'mechanize'
end


Shoes.setup do
gem 'mechanize'
end

--------------------------------------------------------------------
The OLD version:
Expand Down

0 comments on commit b409ce9

Please sign in to comment.