-
Notifications
You must be signed in to change notification settings - Fork 0
/
pg3.rb
41 lines (27 loc) · 922 Bytes
/
pg3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'open-uri'
require 'nokogiri'
require 'mechanize' ##
agent = Mechanize.new
##page =
page = agent.get("http://www.perfectgame.org/")
# <div id="Header2_HeaderTop1_pSignIn" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'Header2_HeaderTop1_Button1')" style="z-index: 7001;">
form = page.form_with(:id => 'Header2_HeaderTop1_tbUsername')
form.login = "[email protected]"
form.password = "my_password"
form.submit
#form = agent.page.form_with(:name => "signdiv")
#form = agent.page.parser.css('form')[0]
#page.form
#puts agent.page.forms[0].fields
#form.length
# def links
# res = []
# doc = Nokogiri::HTML(open("http://www.perfectgame.org/Rankings/Players/Default.aspx?gyear=2015&num=500"))
# doc.css("tr.ranking_row, tr.ranking_alt_row").each do |row|
# row.css("td:eq(4) a").each do |link|
# res << link.attr('href')
# end
# end
# res
# end
# puts links.inspect