4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mechanize#post はブロックを取らない

Last updated at Posted at 2013-11-12

Mechanize を使っていてハマったのでメモ。
ちゃんと Doc 見てなかった自分が悪いんだけども。
参考:Mechanize Document

GETする場合、以下のようにブロックを使って書ける

@agent = Mechanize.new
@agent.get("http://example.com/") do |page|
  p page.body
end

POSTする場合、以下のようにブロックを使って書け ない

@agent = Mechanize.new
@agent.post("http://example.com/", "post_data") do |page|
  p page.body
end
  • POSTする場合、以下のように書くことになる
@agent = Mechanize.new
page = @agent.post("http://example.com/", "post_data")
p page.body

この違いはなんなんだろう・・・or2

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?