回答編集履歴

2

補足

2016/11/11 08:18

投稿

otn
otn

スコア84647

test CHANGED
@@ -17,6 +17,8 @@
17
17
  > ログイン後のページの遷移の書き方がいまいち理解できていなくて
18
18
 
19
19
 
20
+
21
+ リンクを`click`したり、フォームを`submit`したり、url指定で`agent.get`したりするとページ遷移します。
20
22
 
21
23
  テストしてませんが、こんな感じで。
22
24
 

1

プログラム修正例

2016/11/11 08:17

投稿

otn
otn

スコア84647

test CHANGED
@@ -9,3 +9,55 @@
9
9
 
10
10
 
11
11
  そもそも書かれているxpathの3文字目の`*`ってどういう意味ですかね?
12
+
13
+
14
+
15
+ #追記
16
+
17
+ > ログイン後のページの遷移の書き方がいまいち理解できていなくて
18
+
19
+
20
+
21
+ テストしてませんが、こんな感じで。
22
+
23
+
24
+
25
+ ```Ruby
26
+
27
+ #!/usr/bin/ruby
28
+
29
+ require 'mechanize'
30
+
31
+ agent = Mechanize.new
32
+
33
+ agent.user_agent_alias = 'Windows Mozilla'
34
+
35
+
36
+
37
+ url = 'https://www.watashi-move.jp/wl/mydata/sphygmomanometer.php?targetDate=2016/07/01'
38
+
39
+ page = agent.get(url)
40
+
41
+ mypage = page.form_with(id: 'form1') do |form|
42
+
43
+ form.loginid = '*'
44
+
45
+ form.password = '*'
46
+
47
+ end.submit
48
+
49
+
50
+
51
+ url = 'https://www.watashi-move.jp/wl/mydata/sphygmomanometer.php?targetDate=2016/07/01'
52
+
53
+ page = agent.get(url)
54
+
55
+ doc = page.root
56
+
57
+ doc.xpath('//tr[@class="day13"]/td[@class="pressureMin"]').text
58
+
59
+ puts doc.xpath('//tr[@class="day13"]/td[@class="pressureMin"]').text
60
+
61
+ end
62
+
63
+ ```