Created
January 29, 2011 00:18
-
-
Save anonymous/801301 to your computer and use it in GitHub Desktop.
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
require 'mechanize' | |
require 'nokogiri' | |
require 'sinatra' | |
get '/:psuid' do | |
find_name params[:psuid] | |
end | |
def find_name(psuid) | |
result = '' | |
a = Mechanize.new | |
a.get('http://psu.edu/ph') do |page| | |
search_result = page.form_with(:name => 'search') do |search| | |
search.uid = psuid | |
end.submit | |
doc = Nokogiri::HTML(search_result.content) | |
word = doc.css('html body form table tr td b')[0].text | |
name = word[21,word.length] | |
new_word = "" | |
name.split(" ").each do |n| | |
n.downcase!.capitalize! | |
new_word << n+" " | |
end | |
result = new_word | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment